doufangyan6862
2018-06-20 10:11
浏览 281
已采纳

PHP - 使用sAMAccountName通过简单绑定连接到LDAP

I'm trying to connect to LDAP that uses simple bind through PHP 7.2.

I used LDAP Admin desktop app to check my settings and everything works. The app uses my sAMAccountName in form of name.surname and password to log me in. I would like to achieve the same thing through PHP but the only way I managed to get a successful login was below:

$ldap_user   = "CN=Name Surname,OU=Users,OU=Sample,DC=sample,DC=othersample";
$ldap_pass   = "myPassword";

$c = ldap_connect("ldap://x.x.x.x", 389);
ldap_set_option($c, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($c, LDAP_ESCAPE_DN, 1);

ldap_bind($c, $ldap_user, $ldap_pass);

However, my goal is to have $ldap_user to be just the name.surname, the same way the app uses it.

Is there a way to achieve that?

图片转代码服务由CSDN问答提供 功能建议

我正在尝试连接到使用简单绑定到PHP 7.2的LDAP。</ p>

我使用LDAP管理桌面应用程序检查我的设置,一切正常。 该应用程序使用我的sAMAccountName以 name.surname </ code>和密码的形式登录。我想通过PHP实现同样的目的,但我设法成功登录的唯一方法是:< / p>

  $ ldap_user =“CN =姓名姓,OU =用户,OU =样本,DC =样本,DC =其他样本”; 
 $ ldap_pass =“myPassword”; 
  
 $ c = ldap_connect(“ldap:// xxxx”,389); 
ldap_set_option($ c,LDAP_OPT_PROTOCOL_VERSION,3); 
ldap_set_option($ c,LDAP_ESCAPE_DN,1); 
 
ldap_bind($ c,$ ldap_user  ,$ ldap_pass); 
 </ code> </ pre> 
 
 

但是,我的目标是让 $ ldap_user </ code>成为 name.surname </ 代码>,与应用程序使用它的方式相同。</ p>

有没有办法实现呢?</ p> </ div>

1条回答 默认 最新

相关推荐 更多相似问题