Link to home
Start Free TrialLog in
Avatar of SirOracle_
SirOracle_Flag for Norway

asked on

How to use the dsadd utility to add a user when there is a comma in the CN-part of the DN

I am trying to update the Active Directory in our testlab with the production Active Directory. I hva chosen to use some batch-scripts with dsquery, dsget, dsadd and dsmod to do this.

But our users are in the form "Firstname, Lastname". For instance, a user with first name "Tom" and last name "Olsen" will come out like this from dsquery: "CN=Olsen\, Tom,OU=MyDepartment,DC=MyDomain,DC=com". But the dsadd utility don't like this:
C:\dsadd user "CN=Olsen\, Tom,OU=MyDepartment,DC=MyDomain,DC=com"
dsadd failed:CN=Olsen\, Tom,OU=MyDepartment,DC=MyDomain,DC=com:The name provided is not a properly formed account name.

I have tried to remove the escape-character (the backslash), but that dosn't help. And thats understandable, since it uses a comma to seperate the DN-parts.

Does anyone know how to accomplish this?
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Kane - TechSoEasy
Jeffrey Kane - TechSoEasy
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SirOracle_

ASKER

Hi TechSoEasy,

It's not the username, but the distinguished name/display name that we use in the form Lastname, Firstname. But you are correct, after some more testing now, I realize that it's not the DN-name that cause the error message, but the username (samid). When I don't spesify a username (parameter -samid and perhaps -upn) dsadd generates a username of the first 20 characters of the CN (Common Name) part of the DN. And since the CN contains a comma, the generated username also contains a comma.

This works:
C:\dsadd user "CN=Olsen\, Tom,OU=MyDepartment,DC=MyDomain,DC=com" -samid TomO -upn TomO@MyDomain.com

Thanks for the help!!
Well... such are the benefits of brainstorming... where no suggestion is a BAD suggestion (except maybe the suggestion to not make suggestions).  :-)