Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

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

$
0
0

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 = "john@gmail.com";

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 SamAccountName@domainName.com.

Can you please tell me why the email address is getting replaced with SamAccountName@domainName.com even if i have set it to "john@gmail.com". I m using apis of activeDirectory.



Viewing all articles
Browse latest Browse all 7132

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>