简体   繁体   English

PHP-LDAP如何将ldap_add()与userPassword和UserAccountControl一起使用

[英]PHP-LDAP How can I use ldap_add() with userPassword and UserAccountControl

I'm using PHP 5.6.31 I have to create LDAP accounts with HTTPS web interface. 我正在使用PHP 5.6.31,必须使用HTTPS Web界面创建LDAP帐户。

I have a problem with two ldap fields: 我有两个ldap字段问题:

  1. UserAccountControl : I have to set 66048 value (544 value works correctly) but i have this error: Warning: ldap_add(): Add: Server is unwilling to perform in C:****\\traitement.php on line 82 UserAccountControl:我必须设置66048值(544值可以正常工作),但是我遇到此错误:警告:ldap_add():添加:服务器不愿意在第82行的C:**** \\ traitement.php中执行
  2. userPassword : The password in my Active Directory seems don't match with the password set on the web interface but no PHP error returned. userPassword:我的Active Directory中的密码似乎与Web界面上设置的密码不匹配,但是没有返回PHP错误。

php code PHP代码

You need to be on a secured connection to modify a password (and probably other security related options). 您需要建立安全连接才能修改密码 (以及其他可能与安全相关的选项)。

Add the following before you call ldap_bind() : 在调用ldap_bind()之前添加以下内容:

ldap_start_tls($ds);

This is a good idea even if you aren't trying to change a password as otherwise your bind operation is cleartext and can be sniffed. 即使您不尝试更改密码,这也是一个好主意,否则您的绑定操作是明文并且可以被嗅探。

Ok i think it can works with tls. 好的,我认为它可以与tls一起使用。 I found an another solution with the COM class: 我用COM类找到了另一个解决方案:

$ADSI = new COM("LDAP:");
$user = $ADSI->OpenDSObject("LDAP://servername/userdn, $ldapadmin, $ldappass, 1);
$user->SetPassword($userNewPass);
$user->SetInfo();

I hope it can help people :) 我希望它可以帮助人们:)

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

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