CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 ldap $Result

Print topic Send  topic

Author Message
miland

Posts: 31
Posted: 05/12/2006, 5:31 AM

I'm using the CCLoginUser function to accept ldap authentication instead of a MySQL table. Login_Button_DoLogin_OnClick in login.php fires function CCLoginUser in common.php. But since, MySQL is no longer a factor, I need to return the varaible $Result back to CCLoginUser so it knows that the authentication was either successful or not.

My question is what should I use in place of "$Result = $db->next_record();" to return back? I tried this but haven't been successful.

  
if($firstName=null)  
{  
  $Result=0;		  
}  
  Else  
{	  
  CCSetSession("UserBean", $userBean);  
$Results=1;  
}  
	  
//echo $firstName;  
//echo $Result;  
  
 return $Result;  

Bottom line is I don't know what to put into $Result so that when it's returned to Login_Button_DoLogin_OnClick, Login_Button_DoLogin_OnClick knows what to do. What's in Login_Button_DoLogin_OnClick is the standard generated code:

  
//Login_Button_DoLogin_OnClick @30-9DE63FBA  
function Login_Button_DoLogin_OnClick(& $sender)  
{  
    $Login_Button_DoLogin_OnClick = true;  
    $Component = & $sender;  
    $Container = CCGetParentContainer($sender);  
    global $Login; //Compatibility  
//End Login_Button_DoLogin_OnClick  
  
//Login @31-8DE77B20  
    global $CCSLocales;  
	  
    if ( !CCLoginUser( $Container->login->Value, $Container->password->Value,   
		$Container->contextsLB->Value)) {				  
        $Container->Errors->addError($CCSLocales->GetText("CCS_LoginError"));  
        $Container->password->SetValue("");  
        $Login_Button_DoLogin_OnClick = 0;  
    } else {  
        global $Redirect;  
        $Redirect = CCGetParam("ret_link", $Redirect);  
        $Login_Button_DoLogin_OnClick = 1;  
    }  
//End Login  
  
//Close Login_Button_DoLogin_OnClick @30-0EB5DCFE  
    return $Login_Button_DoLogin_OnClick;  
}  
//End Close Login_Button_DoLogin_OnClick  
   
View profile  Send private message
feha


Posts: 712
Posted: 05/12/2006, 10:42 AM

Hi
You don't need to use built in function for auth as it read data from table ...

You need to create your own function
and authenticate from LDAP ...
as i don't know the sturcture of your application I can't give any answer.

to call your custom function you need to modify:
  
//Login @31-8DE77B20    
    global $CCSLocales;    
	    
    if ( !MY_LDAP_FUNCTION( $Container->login->Value, $Container->password->Value,     
		$Container->contextsLB->Value)) {	  
...  

example
  
function MY_LDAP_FUNCTION( $login, $password,  $contextsLB)  
 {	  
//do something  
if( something ok)  
{  
CCSetSession("UserBean", $userBean);    
  
}  
else  
{  
return false;  
}  
  
}  


_________________
Regards
feha

www.vision.to
feedpixel.com
View profile  Send private message
miland

Posts: 31
Posted: 05/12/2006, 11:07 AM

I understand what you are saying but I've actually written the ldap functions and tested (I know that it's working). I kept the orginal function names and some of the code (making sure to delete references where it was pointing to MySQL table). My problem is that CCLoginUser function is looking for a return variable to say everything went okay. I went ahead and just set $Result = true; but now I can't get CCS to advance to the next page which is CorpExt.ccp.

How do you debug this stuff? Any way to set break points or am I dreaming?
View profile  Send private message
feha


Posts: 712
Posted: 05/12/2006, 11:10 AM

if true
add
return true;

if false just add
return false;
  
if(this is ok)  
{  
return true;  
}  
else  
{  
return false;  
}  
no need to use variable $result ....

_________________
Regards
feha

www.vision.to
feedpixel.com
View profile  Send private message
feha


Posts: 712
Posted: 05/12/2006, 11:13 AM

  
if ( !CCLoginUser( ...  

it expects true or false ....
it means if not true ....
_________________
Regards
feha

www.vision.to
feedpixel.com
View profile  Send private message
miland

Posts: 31
Posted: 05/12/2006, 11:28 AM

I am positive that the ldap function is working correctly because I can echo $userBean->firstName; and get the firstname (that wouldn't be possible without authenticating ldap (login name and first name are different). But, my login form is clearing out (login name and password, all reset) instead of moving on to CorpExt.ccp page. If I mess up and put the wrong password, I get a message back saying "Login, Password or Context is incorrect" which is correct.

How would you test to see why it isn't advancing to the next page?

View profile  Send private message
feha


Posts: 712
Posted: 05/12/2006, 11:35 AM

I'm sorry but I'm not in position to answer as I have no idea how you connect what is you retrive and from where ...

Login error will show if you did not set session for userID, gruoupID etc ...


_________________
Regards
feha

www.vision.to
feedpixel.com
View profile  Send private message
miland

Posts: 31
Posted: 05/12/2006, 11:43 AM

I turned off the restricted status of CorpExt.ccp and logged in. Guess what? Successfully logged in and advanced to CorpExt.ccp. See! You did know how to help me!

That means that CCSetSession("UserBean", $userBean); is not working correctly and would advance.

Thank you for you help!
View profile  Send private message
peterr


Posts: 5971
Posted: 05/12/2006, 11:44 AM

I didn't analyze this topic in detail, but I'd like to point out that it's not important how a custom login function works. It only needs to create the 3 session variables:
$_SESSION["UserID"] = "1";
$_SESSION["UserLogin"] = "James";
$_SESSION["GroupID"] = "10";

The Login_Button_DoLogin_OnClick doesn't do anything, except calling some function that creates those variables, then it redirects the user to the next page.
Therefore you can modify:
    if ( !CCLoginUser( $Container->login->Value, $Container->password->Value,     
		$Container->contextsLB->Value))

to call your own function that creates those session variables and returns true or false, like:
    if ( !MyLDAPFunction( $Container->login->Value, $Container->password->Value,     
		$Container->contextsLB->Value))

I'm just not sure what is $Result and why it's being discussed here...
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
feha


Posts: 712
Posted: 05/12/2006, 12:32 PM

:-)
_________________
Regards
feha

www.vision.to
feedpixel.com
View profile  Send private message
miland

Posts: 31
Posted: 05/12/2006, 12:50 PM

Peter, I did indeed discover the importance of the Session variables you talked about above. Thanks for your input. ;-)
View profile  Send private message
peterr


Posts: 5971
Posted: 05/12/2006, 1:03 PM

Well, I don't know what was the problem and was the fix, but I'm glad you're up and running :-)
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.