我设法做到了
connect, query and add to AD
. 添加时
user object
具有
示例a
(向下看)
attributes
设置我没有问题,但是当我添加:
$this->newUserEntry["UserAccountControl"] = 512; //LDAP will disable the account by default, This will create it in an enabled state
我收到以下警告
ldap_add()
和
用户对象
未创建:
Server is unwilling to perform
示例A:
$this->newUserEntry["objectclass"][0] = "top";
$this->newUserEntry["objectclass"][1] = "person";
$this->newUserEntry["objectclass"][2] = "organizationalPerson";
$this->newUserEntry["objectclass"][3] = "user";
//---------General Tab-----------------------------------------
$this->newUserEntry['givenname'] = $this->givenName; //first name
$this->newUserEntry['sn'] = $this->sn; // last name
$this->newUserEntry["displayname"] = $this->sn.', '.$this->givenName; // display name - Format: Meow, Test
$this->newUserEntry["physicalDeliveryOfficeName"] = $this->location; //office
$this->newUserEntry["mail"] = $this->userMail;
$this->newUserEntry["mailNickname"] = $this->userMail; // user mail
//Change this to mobile field
$this->newUserEntry["telephoneNumber"] = '9897157910'; // user phone
//----------Account Tab----------------------------------------
$this->newUserEntry["userPrincipalName"] = $this->samaccountname.'@comp.com'; //User logon name
$this->newUserEntry["sAMAccountname"] = $this->samaccountname; //pre windows 2007 logon name
//----------profile Tab-----------------------------------------
$this->newUserEntry["scriptPath"] = $this->scriptPath; //Log on script
//----------Organization Tab------------------------------------
$this->newUserEntry["title"] = $this->title;
$this->newUserEntry["department"] = $this->department; // department
$this->newUserEntry["company"] = "Open Doors Test"; // Company name
$this->newUserEntry["manager"] = $this->managerDn; // name of the manager
我尝试过:
1-设置
password attribute
:
我告诉大家这是因为我没有密码
attribute
设置,所以我尝试添加
password
具有
hashing
而且没有
散列
:
密码示例:As33557b
$this->newUserEntry["userPassword"] = '{MD5}' . base64_encode(pack('H*',md5($this->password))); //md5HASH - hash the password
这两次尝试都失败了,就像以前一样,如果我删除帐户控制,则创建的用户对象没有任何问题。
2-确保连接已结束
SSL
:
我改变了通过
LDAP
:
之前:
ldap_connect('ldap://'. $this->dnToConnect)
之后:
ldap_connect('ldap://'. $this->dnToConnect, 636)
我也跑了
nmap -p 636 mydomain.com
确保
port is open
我可以建立联系。
3-尝试设置
512
值作为
string
作为一个
integer
.
笔记:
我可以
accounts, disable and enable
手动执行,因此问题不应出现在
user and password
我已经习惯了
bind
.
更新1:
我已将问题缩小到密码。我可以创建
Enabled account
具有
no password
和设置
userAccountControl to 544
,因此我认为问题在于我设置密码字段的方式。
Bloob就要爆炸了,如果有人帮忙,我们将不胜感激。
评论部分请求的信息:
密码:
最初,我将密码设置为:
//$this->newUserEntry["userPassword"] = '{MD5}' . base64_encode(pack('H*',md5($this->password))); //md5HASH - hash the password
而不是有人建议尝试将其设置为:
$newPassword = $this->password;
$newPassword = "\"" . $newPassword . "\"";
$newPass = mb_convert_encoding($newPassword, "UTF-16LE");
$this->newUserEntry["unicodePwd"] = $newPass;