Active Directory null result



I am using VS.NET 2005 to build a Web Application. I need to Query
Active Directory to find to which "Department" the current logged in
User belongs.

in web.config i have set Windows Authentication and identity
impersonate to true.
On my development computer, without a problem i can build the
application and the query returns the "Department" of the particular
user using the following code:

Dim entry As New DirectoryEntry("LDAP://dc=mot,dc=gov")
Dim Dsearch As New DirectorySearcher(entry)
Dsearch.Filter = "(&(objectClass=user)(sAMAccountName=" +
Environment.UserName + "))"
Dim search As SearchResult = Dsearch.FindOne
If Not (search Is Nothing) Then
labSection.Text =
labSection.Text = "Empty"
End If

But once i put the files on the WIndows 2000 Server IIS virtual
directory i get the page but the labSection shows "Empty".

in the IIS directory security , Under "Authentication Methods" i have
ticked only "Intergrated Windows Authentication"

I am using version 2.0

After searching & reading forums, i am still unable to find the reason
for this. Please help as i am stuck on this for more than a week. Any
suggestion or alternative methods are welcome.


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question