locked
System.DirectoryServices.DirectoryServicesCOMException: A constraint violation occurred RRS feed

  • Question

  • While trying to create a new AD account and reaching this line of code...

    userPrincipal.Save();

    ...I get this exception :

    System.DirectoryServices.DirectoryServicesCOMException: A constraint violation occurred.

    When debugging in Visual Studio I see the following under ExtendedErrorMessage:

    "000021C8: AtrErr: DSID-03200BD2, #1:\n\t0: 000021C8: DSID-03200BD2, problem 1005 (CONSTRAINT_ATT_TYPE), data 0, Att 90290 (userPrincipalName)\n"

    It seems like some Active Directory constraint is being violated, but the error does not specify which one or why, or at least I cannot figure out from the ExtendedErrorMessage. Any help greatly appreciated!

    Wednesday, January 16, 2019 5:23 PM

All replies

  • The error message seems to indicate a problem with the userPrincipalName attribute. But the only constraint I am aware of is a limit of no more than 1024 characters. ADUC enforces uniqueness in the domain, but I never found code that does. I have created duplicates myself in my lab domain.

    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Wednesday, January 16, 2019 7:07 PM
  • I agree with Richard. You may want to display the attribute value to see its length. You can as well try to do the same manually using the same account and see what it gives. If all goes well manually then you may want to check on the MSDN forums if there are code specific syntax to use.

    This posting is provided AS IS with no warranties or guarantees , and confers no rights.

    Ahmed MALEK

    My Website Link

    My Linkedin Profile

    My MVP Profile

    Wednesday, January 16, 2019 7:21 PM
  • Hello,
    Thank you for posting in our TechNet forum.

    According to our description, I found a similar case,  we might need to change the code we are calling to solve the problem.

    For details we can refer to 
    Constraint Violation When Creating AD User Object with account management extension class attributes .

    Tip: This answer contains the content of a third-party website. Microsoft makes no representations about the content of these websites. We provide this content only for your convenience.


    Best Regards,
    Daisy Zhou

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Thursday, January 17, 2019 5:58 AM
  • Hi,
    If this question has any update? Also, for the question, is there any other assistance we could provide?

    Best Regards,
    Daisy Zhou

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, January 21, 2019 12:55 AM
  • Hi,
    Would you please tell me how things are going on your side. If you have any questions or concerns about the information I provided, please don't hesitate to let us know. 
     
    Again thanks for your time and have a nice day!

    Best Regards,
    Daisy Zhou

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Wednesday, January 23, 2019 1:16 AM