Navigation

Sunday 23 November 2014

Constraint violation occurred active directory C# Directory Services

While creating user accounts in active directory using Directory Services through C# we commonly encounter error  Constraint violation occurred.
This is an error which gives the generalized error message where developers can not find the reason of exception or error details exactly. Same way i have wasted 2 hours of time on this error to find out the exact reason and common scenarios related to it. This is because of following cases,

1. When we try to update the country attribute  'c' with string: - Country attribute should be set with only 3 characters or less, if we try to update 'c' attribute with string more than 3 characters length we face Constraint violation occurred error.

In the same way if we try to update any attribute with data that violates it's constraints we may face this generalized error so please make sure you are updating attributes with correct information.

For all attributes information please follow my previous post 

Note: Exception is thrown only at de.CommitChanges(); (de is instance of DirectoryEntry type) irrespective of all lines of code where we set attributes before this line

No comments:

Post a Comment