Update value Declaration attribute for null or empty get errror?
Here's the code to update mail, department, header and mobile to zero or empty AD user value.
var adSearch = new DirectorySearcher(ConnectHelper.ContxEntry);
adSearch.Filter = "samAccountName=" + "....";
var result = adSearch.FindOne();
if (result != null)
{
DirectoryEntry user = result.GetDirectoryEntry();
user.Properties["mail"].Value = null;
user.Properties["Department"].Value = null;
user.Properties["Title"].Value = null;
user.Properties["mobile"].Value = null;
user.CommitChanges();
}
Error: "The syntax for the attribute specified for the directory service is invalid."
How can I set the value of some properties to null or empty?
+3
source to share