Using VB.NET
Trying to retreive the 'givenname' and 'SN' from Active Directory using the following code:
<snip>
oSearcher.Filter = "(&(objectCategory=user)(objectClass=user)(samaccountname=" & pUsername & "))"
oSearcher.PropertiesToLoad.AddRange(New String() {"givenName", "SN"}
Try
oResults = oSearcher.FindAll
For Each oResult In oResults
returnVal = oResult.Properties("givenname").ToString()
Next
Open in new window
but 'returnVal' is set to: "System.DirectoryServices.
ResultProp
ertyValueC
ollection"
and not the givenname
The 'DirectoryEntry' for my DC etc. is correct as I'm using the same thing for another query that works just fine and is very similar to this one.
I get no actual error, just not gettng the data I need
What am I missing?