成功创建用户后,我无法使用用户名登录 和密码。它显示凭证无效。当我进入 正确的用户名和密码。 我对php有一点了解。请指导我。谢谢。
$username = "ntop\administrator";// ldap server username
$password = "******";// ldap server password
$ldap_server = "*.*.*.*"; ldap sever ip
$name="sunill"; //common name
$email="sunil@gmail.com";
$pwd="mohdali@123456";
$ldap_conn = ldap_connect($ldap_server);// ldap connectivity
ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3) or die
("Could
not set LDAP Protocol version");
if($ldapbind = ldap_bind($ldap_conn, $username, $password) == true)
{ // if ldap bind
$adduserAD["cn"] = $name;// Common name
$adduserAD["givenname"] = $name;
$adduserAD["sn"] = 'Kumar'; // Surname
$adduserAD["sAMAccountName"] = $name; // SamaAccountname declare here
$adduserAD['userPrincipalName'] = $name;
$adduserAD["objectClass"] = "User"; // Object class user
$adduserAD["displayname"] = "Test User";
$adduserAD['mail'] = $email;
$adduserAD["userPassword"] = $pwd; // set password here
$adduserAD["userAccountControl"] = "66080";
$base_dn = "cn=".$name.",ou=Netmetric,DC=ntop,DC=local";// base dn
// Attempt to add the user with ldap_add()
if(ldap_add($ldap_conn, $base_dn, $adduserAD) == true){
echo "User is created";
}
ldap_close($ldap_conn);
}else{
echo "Not connected with server";
}