Jul 11, 2017 09:05 PM|PatriceSc|LINK
This error means you are trying to access a member while the object is null so the usual approach is to use the debugger and check each and every object used on this line to find which one is null ie check de, de.Properties, de.Properties etc... until
to find which one is null.
Not directly related but with 4.x or later you have https://msdn.microsoft.com/en-us/library/system.directoryservices.accountmanagement.userprincipal.findbyidentity(v=vs.110).aspx
which can ease a bit using AD.
Edit: ah could it be just that an exception is thrown in which case you return null. So you would have to check de to see if this is null. You could also reconsider this. By catching inside this function, the caller can't get any information about the exception
and it's easy to even forget that it could return null and to check for that (which is why we moved away from result code to exceptions).