Point Deep

Mundeep's Tech Blog

Clearing Active Directory Values in C#

Posted by mundeep on August 5, 2008

To clear values in Active Directory they must be set to NULL and not “” or empty.
This can easily be done by using the Clear() method on the property value collection for the active directory field you wish to update.

using System.DirectoryServices;

public void ClearAdField(string fieldName, DirectoryEntry adEntry) {
  PropertyValueCollection adValue = adEntry.Properties[fieldName];
  adValue.Clear();
  adEntry.CommitChanges();
}
Advertisements

One Response to “Clearing Active Directory Values in C#”

  1. Anonymous said

    adResult.Properties(“FIELDNAME”).Clear()

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: