2

I need update a specific user ldap with new custom attributes. When run throw Exception "Unhandled Exception: System.DirectoryServices.DirectoryServicesCOMException: The specified directory service attribute or value does not exist". My code is:

using (var entryRoot = new DirectoryEntry("LDAP://ldap.com:389/OU=CATALOG,DC=ldap,DC=com", "juan", "juan2016", AuthenticationTypes.Secure)){
    DirectorySearcher user_searcher = new DirectorySearcher(entryRoot);

    user_searcher.Filter = $"(&(objectCategory=person)(objectClass=user)(samAccountName={cn1}))"

    user_searcher.PropertiesToLoad.Add("identification");

    SearchResultCollection result = user_searcher.FindAll();

    DirectoryEntry user_ldap = result[0].GetDirectoryEntry();

    user_ldap.Properties["identification"].Value = identification;

    user_ldap.CommitChanges();
}
2
  • Seems like you'll need to add the attribute to the user before trying to set it to something... Commented Jun 12, 2018 at 18:42
  • 1
    Did you add the identification attribute to your schema manually? It's not a valid attribute out of the box. Commented Jun 13, 2018 at 2:03

1 Answer 1

1

Add the customs attributes in "Active Directory Schema" and assign to user class as optional attribute, after runed my code and successful result

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.