Unable to create user with password (Active Directory)
See original GitHub issueHi guys,
I still have the same issue as #31 and cannot fix it… I connect to LDPA using SSL and after i can get infos from AD create OU etc But when i try to create a user i receive the same error as described in this topic.
0000001F: SvcErr: DSID-031A1254, problem 5003 (WILL_NOT_PERFORM), data 0
Creation of user without password working well…
Thanks
There are the code that i use to connect to AD:
- Connection
LdapConnection conn = new LdapConnection();
conn.SecureSocketLayer = true;
conn.UserDefinedServerCertValidationDelegate += (sender, certificate, chain, sslPolicyErrors) => true;
conn.Connect(this.ADExtHost, 636);
conn.Bind(LdapConnection.Ldap_V3, this.ADExtLogin, this.ADExtPassword);
- Adding user to AD
LdapAttributeSet attributeSet = new LdapAttributeSet();
attributeSet.Add(new LdapAttribute("userPrincipalName", username + "_" + domain + "@external.local"));
attributeSet.Add(new LdapAttribute("mail", user.Email));
attributeSet.Add(new LdapAttribute("objectClass", new string[] { "user", "organizationalPerson", "person", "top" }));
attributeSet.Add(new LdapAttribute("name", user.Email));
sbyte[] encodedBytes = SupportClass.ToSByteArray(Encoding.Unicode.GetBytes(password));
attributeSet.Add(new LdapAttribute("unicodePwd", encodedBytes));
attributeSet.Add(new LdapAttribute("userAccountControl", "544"));
//DN of the entry to be added
string dn = $"cn={user.Email}," + container;
LdapEntry newEntry = new LdapEntry(dn, attributeSet);
//Add the entry to the directory
connection.Add(newEntry);
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Can not reset User's Password and Cannot create user in ...
Can not reset User's Password and Cannot create user in Active directory. We can password reset and also can create new user in...
Read more >Error: Unable to create a user - Microsoft Q&A
In my case I got a error message when I tried to entered the password manually. Try autogenerate option while create a user...
Read more >[SOLVED] Unable to create new AD user because....
Windows cannot create the object <users first and last name> because: The directory service was unable to allocate a relative identifier.
Read more >Can not reset User's Password and Cannot create user in ...
1 Answer 1 ... Windows cannot complete the password change for __ because: The password does not meet the password policy requirements. Check...
Read more >Unable to create Users, Groups, or OUs
When I go to Windows > Administrative Tools > Active Directory Users and Computers, I get a message that says "To manage users...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
if I’m not misstaken, we got it working by enclose the password with " before encoding to sbytes. Like:
clearTextpassword = "\"" + clearTextpassword + "\""; sbyte[] encodedBytes = SupportClass.ToSByteArray(Encoding.Unicode.GetBytes(clearTextpassword));
I can not believe it ! it’s working now! I managed to create a new user with password. Thank you very much for this trick, you saved my migration to .NET CORE 😃)))
PS. To DEV team, this ticket can be closed right now