Last post Aug 15, 2011 02:07 PM by gww
Aug 12, 2011 01:41 AM|patelabhijeet|LINK
I'm using DirectoryServices to query for DirectoryEntries for a person or group like so:
The issue I'm having is that the above call for getting the DirectoryEntry for the SearchResult is fetching more properties than what I'm querying for. If I hover over the "searchResult" while debugging, it contains just the 8 properties I queried for but
calling "GetDirectoryEntry()" on the "searchResult" queries for a ton more properties(approx 77 - 80 more property values).
The real problem is that it is also querying for properties whose "confidential bit" is set such as'UnixUserPassword'causing audit failures on the DC.
Is there any way to specify NOT to query for any properties having the confidential bit set OR have the "result.GetDirectoryEntry()" respect my "propsToLoad" and only fetch property values for properties that I've specified on the "DirectorySearcher".
Aug 12, 2011 08:59 AM|gww|LINK
you would use something like s.PropertiesToLoad.Add("cn") before s.FindOne()
Aug 12, 2011 01:12 PM|patelabhijeet|LINK
Isn't that the same as specifying the properties to load in the DirectorySearcher's constructor?
DirectorySearcher dSearch = new DirectorySearcher(dEntry, "(&(|(objectClass=person)(objectClass=group)) (samAccountName=jsmith))", propsToLoad);
var searchResult = dSearch.FindOne();
Aug 15, 2011 02:07 PM|gww|LINK
I havent actually seen it done that way. I have always just used the searcher as DS(DE) and then applied the filter and properities to add as i listed above. I couldnt find an example with it all in the same DE as you have listed. But if that is correct
it should work. Maybe the string needs formatted differently.