I'm trying to return anattribute an identify if it has null or emtpy value. I know if i give the attribute a value it returns it find, but if it has no value it returns "object reference not set to an instance of an object"! How do i identify an empty value other than if x ==null or string x =""?
I have to return this attriute and identify if the attribute is emtpy, so i can't use a collection to output all attributes in a foreach..
any ideas would be appreciated thank you very much!
DirectoryEntry entry = new DirectoryEntry("LDAP://" + dom);
DirectorySearcher mySearcher = new DirectorySearcher(entry);
mySearcher.PropertiesToLoad.Add("msExchHomeServerName");
mySearcher.Filter = "(&(objectCategory=person)(objectClass=user)(proxyaddresses=smtp:" + strsmtp + "))";
foreach (SearchResult resEnt in mySearcher.FindAll())
{
DirectoryEntry de = resEnt.GetDirectoryEntry();
string msExchHomeServerName = de.Properties["msExchHomeServerName"].Value.ToString();
if (msExchHomeServerName == null)
{
textBox10.Text += "Object is null" + msExchHomeServerName;
}
}