question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to create user with password (Active Directory)

See original GitHub issue

Hi 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:

  1. 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);
  1. 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:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Rat70commented, Feb 5, 2019

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));

0reactions
maxis777commented, Feb 5, 2019

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found