简体   繁体   English

检查用户名和密码vie ldap php

[英]check username and password vie ldap php

I'm trying to connect to my AD server and check if username and password is correct when I'm trying to do that, it always tells me: 我正在尝试连接到我的AD服务器,并在尝试这样做时检查用户名和密码是否正确,它总是告诉我:

Unable to bind to server: Invalid credentials 无法绑定到服务器:无效的凭据

My code is: 我的代码是:

$ldapconn = ldap_connect($adserver,$adport);
$ldapbind = @ldap_bind($ldapconn,"$username","$password");

When I tried to set a username with and without domain name in this variations: user@domain.co.il domain\\user user 当我尝试在此变体中设置带或不带域名的用户名时:user@domain.co.il domain \\ user user

When I'm trying to bind anonymously, Its ok. 当我尝试匿名绑定时,可以。 Do you have any suggestion here? 您有什么建议吗?

If you use Active directory then you must set this options: 如果使用Active Directory,则必须设置以下选项:

ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($ ldapconn,LDAP_OPT_PROTOCOL_VERSION,3);

ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0); ldap_set_option($ ldapconn,LDAP_OPT_REFERRALS,0);

and use FULL DN (ex. uid=UserName,cn=Peoples,dc=example,dc=com) or short version (UserName@example.com) AD supports both types. 并使用完整DN(例如,uid = UserName,cn = Peoples,dc = example,dc = com)或简称(UserName@example.com)AD支持两种类型。

Check username. 检查用户名。 It should be a properly formatted RDN/DN. 它应该是格式正确的RDN / DN。 Special characters must be escaped. 特殊字符必须转义。

It would help if you post the value of $username . 如果发布$username的值,则将有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM