Authentication osTicket使用开放目录进行身份验证
我们最近建立了osTicket票证系统,并一直在测试它,看看是否在我们的办公室实施。如果能够根据现有的开放目录进行身份验证,这将非常有帮助。我发现了一篇文章(),其中讨论了如何使用Active Directory并通过替换以下代码来编辑class.staff.php文件:Authentication osTicket使用开放目录进行身份验证,authentication,ldap,Authentication,Ldap,我们最近建立了osTicket票证系统,并一直在测试它,看看是否在我们的办公室实施。如果能够根据现有的开放目录进行身份验证,这将非常有帮助。我发现了一篇文章(),其中讨论了如何使用Active Directory并通过替换以下代码来编辑class.staff.php文件: /*compares user password*/ function check_passwd($password){ return (strlen($this->passwd) && st
/*compares user password*/
function check_passwd($password){
return (strlen($this->passwd) && strcmp($this->passwd, MD5($password))==0)?(TRUE):(FALSE);
}
新守则是:
/*compares user password*/
function check_passwd($password){
// Change made for LDAP Auth based on -> http://osticket.com/forums/showthread.php?t=3312
// Change this line to the FQDN of your domain controller
$ds=ldap_connect('mydc.mydomain.local') or die("Couldn't connect to AD!");
// Change this line to the name of your Active Directory domain
if ($ds) {
$domain="mydomain";
$ldapbind = ldap_bind($ds);
if (!@ldap_bind( $ds, $domain."\\".$this->username, $password) ) {
// Auth failed! lets try at osTicket database
return (strlen($this->passwd) && strcmp($this->passwd, MD5($password))==0)?(TRUE):(FALSE);
// return(FALSE);
}
else{
// Auth succeeded!
return(TRUE);
}
// End Changes
}
}
然而,我似乎仍然无法连接。我假设这是因为我需要使用OD而不是Active Directory。任何帮助都将不胜感激
谢谢,,
Aaron您的问题是,它试图在传入的值和目标目录中的值之间进行密码比较 您添加的行:
strlen($this->passwd)和&strcmp($this->passwd,MD5($password))==0)?(TRUE)
正在尝试对用户输入的密码进行MD5哈希,并与检索到的密码进行比较
但这就产生了两个巨大的假设,即您连接的目录也是:
测试绑定更好,因为它在大多数目录系统中也增加了最后登录时间。您可以使用此功能,它工作正常:
function check_passwd($password){
$adServer = "ldap://dc.yourdomain.com";
$ldap = ldap_connect($adServer);
$username = $this->username;
$password = $this->passwd;
$ldaprdn = 'yourdomain' . "\\" . $username;
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
$bind = @ldap_bind($ldap, $ldaprdn, $password);
if ($bind) {
echo "SUCCESS";
return true;
}
else {
echo "FAILUR";
return false;
}
}
谢谢你对此的回复。我对这一切都不太熟悉。我将如何进行测试绑定?