Hi All
I’m trying to setup the LDAP authentication. Have searched from the exisiting topics but could not make it worked.
My PHPMaker version : 2020.0.16
What I have done so far:
- Advance Settings
- LDAP host name : company AD server name
- LDAP port number: 389 (leave as default)
- LDAP distinguished name : domaim{user}
- LDAP option : leave it blank (have no idea what to put in)
- Server event (Usewr_CustomValidate)
Have read from server event help and copied below to the script.
if (IsAuthenticated()) { // Windows authentication
$ar = explode(“\”, $usr);
if (count($ar) > 1)
$usr = $ar[1]; // Return the user name only
}
- re-generated
cannot pass the login screen even I have typed in a correct user name and password 
anythign else I have missed?
thanks
arbei
2
Thanks for the reply. Still not able to get this passed.
My code is below. Keep getting “Invalid credential!!” and “Incorrect user name or password” error, even I used the correct one.
function User_CustomValidate(&$usr, &$pwd) {
// Enter your custom code to validate user, return TRUE if valid.
global $Page;
$ldap_dn = “uid=”.$usr.“,dc=domain,dc=com”;
$ldap_password = $pwd;
$ldap_con = ldap_connect(“il.domain.com”);
ldap_set_option($ldap_con, LDAP_OPT_PROTOCOL_VERSION, 3);
if(@ldap_bind($ldap_con,$ldap_dn,$ldap_password))
{
//echo “Authenticated”;
$Page->setMessage(“Authenticated”);
return TRUE;
}else{
//echo “Invalid Credential”;
$Page->setMessage(“invalid credential!!”);
return FALSE;
}
}
Advance settings:
- LDAP host name : il.domain.com
- LDAP port number: 389
- LDAP distinguished name : domaim{user}
- LDAP option :
arbei
4
arbei wrote:
Read:
http://hkvforums.com/viewtopic.php?f=4&t=42540
Your $ldap_dn may not be correct.
Thanks
you’re right, removed DC from $ldap_dn then it works as expected.
Before:
$ldap_dn = “uid=”.$usr.“,dc=domain,dc=com”;
after changed:
$ldap_dn = $usr;
Thanks again