Mohit Shah

Mohit Shah

  • NA
  • 1
  • 1.5k

How to set email to a user in Active Directory using c#

May 8 2013 1:27 AM
I have programatically created a user in Active Directrory. I want to set email to that user. I used the following code to set email address in active directory:

UserDirectoryEntry.Properties["mail"].Value = "[email protected]";
UserDirectoryEntry.CommitChanges();

At this point, the email address gets set in active directory properly. But the moment, i try to update another property for that user say for eg:

UserDirectoryEntry.Properties["telephoneNumber"].value = "022-2345678"; UserDirectoryEntry.CommitChanges();

After this point, the email address that we set earlier to "mail" field gets replaced with [email protected].

Can you please tell me why the email address is getting replaced with [email protected] even if i have set it to "[email protected]". I m using apis of activeDirectory.