Sunday, March 20, 2011

AD Domain question

In active directory on the user properties dialog and the account Tab there is a field. The first textbox at top left is "User login name:”, to the right of that there is a dropdown with @domain.local. Does anyone know what property or object needs to be populates to put a value here when creating user programmatically?

From stackoverflow
  • That's the userPrincipalName (UPN). You typically set it to the value of sAMAccountName and add @domain.local. If your using the dsadd user command you need to specify the -upn parameter for this to be populated.

    Gene Butler : NewUser.Properties["userPrincipalName"].Value =strLoginName; Populates the only "User login name:” field NewUser.Properties["userPrincipalName"].Value = "@MyDomain.local"; Popluate only the domain field NewUser.Properties["userPrincipalName"].Value = strLoginName + "@MyDomain.local"; Populates both..... Thanks so much for your help!!!
    Per Noalt : Always use NewUser.Properties["userPrincipalName"].Value = strLoginName + "@MyDomain.local"; - setting just one will result in errors. userPrincipalName is stored as a whole string in AD. If you're happy with the answer click on the up arrow and the check mark to accept my answer.


Post a Comment