我在使用ldap_add()通过php创建一个新帐户时遇到错误,这是一个奇怪的错误,因为某些名称不起作用。错误是约束违规(19)。这个问题的大小不是问题所在,因为我尝试过较小的问题而且很好。用这个把头发拉出来。
$user = "username";
$psw = "password";
$server = "com-ads-04s.domain.co.uk";
$ds=ldap_connect($server);
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION,3);
ldap_set_option($ds, LDAP_OPT_REFERRALS,0);
$r=ldap_bind($ds, $user , $psw);
$hDrive = "\\\\sub.domain.co.uk\Area\users\homefoldersA-B\Affan.Ghani";
$starter_with_space = "Affan Ghani";
$firstName = "Affan";
$lastName = "Ghani";
$starter_with_dot = "Affan.Ghani";
$NewUserAD["homedirectory"] = $hDrive;
$NewUserAD["cn"] = $starter_with_space;
$NewUserAD["sn"] = $lastName;
$NewUserAD["givenname"] = $firstName;
$NewUserAD["objectclass"][0] = "top";
$NewUserAD["objectclass"][1] = "person";
$NewUserAD["objectclass"][2] = "organizationalPerson";
$NewUserAD["objectclass"][3] = "user";
$NewUserAD["displayname"][0] = $starter_with_space;
$NewUserAD["displaynameprintable"][0] = $starter_with_space;
$NewUserAD["proxyaddresses"][1] = "SMTP:".$starter_with_dot."@domain.co.uk";
$NewUserAD["userprincipalname"] = $starter_with_dot."@domain.co.uk";
$NewUserAD["mail"] = $starter_with_dot."@domain.co.uk";
$NewUserAD["userprincipalname"] = $starter_with_dot."@domain.co.uk";
$NewUserAD["samaccountname"] = $starter_with_dot;
$NewUserAD["useraccountcontrol"][0] = 544;
$NewUserAD["objectcategory"][0]= "CN=Person,CN=Schema,CN=Configuration,DC=domain,DC=co,DC=uk";
$NewUserAD["name"][0] = $starter_with_space;
$NewUserAD["objectcategory"][0] = "CN=Person,CN=Schema,CN=Configuration,DC=domain,DC=co,DC=uk";
$userWithOU = "CN=".$starter_with_space.",OU=Services,OU=UserDepartments,OU=Test,DC=domain,DC=co,DC=uk";
$NewUserAdded = ldap_add($ds,$userWithOU,$NewUserAD)
经过一番调查后我发现它是导致它的$NewUserAD["homedirectory"]
,所以我开始在用户界面添加随机内容,所以这些不起作用:
\\sub.domain.co.uk\Area\users\homefoldersA-B\Affan.Ghani
\\sub.domain.co.uk\Area\users\homefoldersA-B\Maff.Mace
\\sub.domain.co.uk\Area\users\homefoldersA-B\Maff.Mace1
\\sub.domain.co.uk\Area\users\homefoldersA-B\Affan.Bo
\\sub.domain.co.uk\Area\users\homefoldersA-B\Maff.Ghani
这样做:
\\sub.domain.co.uk\Area\users\homefoldersA-B\Maff1.Mace
\\sub.domain.co.uk\Area\users\homefoldersA-B\Jo.Bo
\\sub.domain.co.uk\Area\users\homefoldersA-B\Jo.Ghani
\\sub.domain.co.uk\Area\users\homefoldersA-B\Maff1.Ghani
有人有任何想法吗? 谢谢