I have try all of the above conditions and none of them
seems to work.
if (dentry.Properties.Contains("telephoneNumber")) {
dentry.Properties["telephoneNumber"].Value =
oEmployee.TelephoneNumber;
} //no update, this is the recommended, runs without any error but does not update the property in AD. It just ignores the second line after the condition.
if (dentry.Properties["telephoneNumber"] !=null) {
dentry.Properties["telephoneNumber"].Value =
oEmployee.TelephoneNumber;
} // No error, runs but does not update the property in AD
if (dentry.Properties["telephoneNumber"] == null) {
dentry.Properties["telephoneNumber"].Value = oEmployee.TelephoneNumber;
} // Exception error. If the telephoneNumber is null in the database, if is not null it will update.
This works only if all the properties to update are not null in the database table:
dentry.Properties["telephoneNumber"].Value = oEmployee.TelephoneNumber;
I have read the whole chapter 6 where It explains about working with nulls and still no answer. What I am trying to do is update Active Directory users with data that comes from a table in x database.
Any help will be very appreciated.