Help Creating User Problem, displayname property. RRS feed

  • Question

  • User-1494647696 posted


    I need to create a user but i am having problems when i put a comma on the displayname property.

    Is there a way to put comma on the displayname property because our naming convension that we use is like this Lastname , Firstname

    This works

    newUser.Properties["displayName"].Add("Lastname Firstname");

    When i include a comma it fails

    newUser.Properties["displayName"].Add("Lastname , Firstname");


    Thanks in advance.

    Tuesday, February 28, 2006 4:18 AM

All replies

  • User1354132231 posted
    You need to escape this character using the '\' character.  In C#:

    @"Lastname\, Firstname"

    Tuesday, February 28, 2006 11:51 AM
  • User-1494647696 posted

    Thanks for the reply,

    Its work just have a little problem.

    By using @"Lastname\, Firstname"

    In Active Directory Users and Computers It displays Lastname, Firstname its perfect.

    but when you look at the user properties in the general tab the displayname text box displays the forward slash character also Lastname\, Firstname is there a work around for this.

    Thanks again...

    Tuesday, February 28, 2006 12:51 PM
  • User1354132231 posted
    Unfortunately, no.  The ',' character is a reserved character, so it will always be escaped when you need a literal value.  The best solution is not to use it at all... :)
    Tuesday, February 28, 2006 1:56 PM