Hi,
My guess is that the webserver is not a member of the domain that it is
querying. This will cause the query to fail.
Regards,
Kueh.
"Jason Wilson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have written a web app in ASP.NET that works fine in VS2005, but
> DirectorySearcher fails when I copy it to the web server.
>
> Here's some code:
>
> Dim sUser As String = Environment.UserName
> Dim adEntry As New DirectoryEntry("LDAP://
> DC=radnet,DC=ausrad,DC=com")
> Dim adSearcher As New DirectorySearcher(adEntry)
> adSearcher.SearchScope = SearchScope.Subtree
> adSearcher.Filter = "(&(objectCategory=person)
> (objectClass=user)(sAMAccountName=" & sUser & "))"
> adSearcher.PropertiesToLoad.Add("mail")
>
> adSearcher.PropertiesToLoad.Add("extensionAttribute1") 'This
> contains employee SSN
> Dim adResult As SearchResult = adSearcher.FindOne
> ***hfUserEmail.Value =
> adResult.GetDirectoryEntry().Properties("mail").Value
> ***hfUserSSN.Value =
> adResult.GetDirectoryEntry().Properties("extensionAttribute1").Value
>
> *** These 2 lines give me: Object reference not set to an instance of
> an object. (nullreference exception)
>
> I've tried adding credentials to the DirectoryEntry with the same
> results.
>
> Thanks in advance,
>
> Jason Wuksib
>
|