Directory Programming .NET

Active Directory and ADAM programming support for .NET developers
Welcome to Directory Programming .NET Sign in | Join | Help
in Search

Changing AD "usernames"?

Last post 06-26-2010, 10:13 AM by joe. 1 replies.
Sort Posts: Previous Next
  •  06-25-2010, 8:19 PM 8441

    Changing AD "usernames"?

    I'd like to be able programmatically to modify AD usernames, and by this I mean the value of the account's "CN" attribute.  When our application logic creates accounts, it sets the end-user-specified username as the "CN" and also as the "sAMAccountName", but doesn't explicitly apply this value anywhere else.

    I understand from Chapter 3 of the book that changing the "CN" attribute itself requires a DirectoryEntry.Rename() call.  However, I'm concerned that this new value no longer matches the original "sAMAccountName", or the original "userPrincipalName", which was implicitly set to "username@domain" when the account was created.  So should or must I also update these attributes manually at the same time in order to keep the account internally consistent?

  •  06-26-2010, 10:13 AM 8443 in reply to 8441

    Re: Changing AD "usernames"?

    There is no relation whatsoever between CN, sAMAccountName and UPN internally. If you want them to have the same value, you must ensure this in your provisioning.

    Some people like to have them be different while some like them to be the same (my preference). It really all comes down to the naming standards for your org. It may be the case that you don't really have any at this level of detail so sometimes that's a good reason to create some. It makes you think about what you want.

    CN is only important in terms of the user object's position within the AD tree. It is not used for login or anything like that so to some extent it does not matter what the value is except that it is unique in its current container. sAMAccountName and UPN are much more important and have global uniqueness requirements with UPN needing to be unique forest-wide.

View as RSS news feed in XML