I'm using the same userID, LDAP connection string to bind to an LDAP server and fetch information.
Tool #1 exposes the msExchMailboxGuid consistently and reliably.
Tool #2 (.NET) doesn't expose the msExchMailboxGuid. There are occasions where it's null, and other instances where it isn't.
(Note: I'm not looking for code /developer support)
DirectoryEntry de = new DirectoryEntry();
de.Path = "LDAP://ldap.exchange.serverdata.net:636/DC=exchange,DC=serverpod,DC=net";
de.Password = "PASSWORD";
de.Username = "LDAP@copmany.com";
de.AuthenticationType = AuthenticationTypes.Secure;
DirectorySearcher ds = new DirectorySearcher();
ds.PropertiesToLoad.Add("cn");
ds.PropertiesToLoad.Add("mail");
ds.PropertiesToLoad.Add("samAccountName");
ds.PropertiesToLoad.Add("msExchMailboxGuid");
ds.PropertiesToLoad.Add("proxyAddresses");
ds.PropertiesToLoad.Add("targetAddress");
ds.PageSize = 800;
ds.Filter = "(&(objectCategory=person)(mail=user1@company.com))";
SearchResultCollection results = ds.FindAll();
This code is very simple, but when I substitute user1@company.com with user2@company.com, the attribute is gone. (but is visible in other tools)
Is there any logical AD reason why an attribute would be missing under certain circumstances? What are those circumstances?
How can I debug this kind of LDAP query?