Active Directory null result

Discussion in 'ASP .Net' started by zifth, Dec 14, 2006.

  1. zifth

    zifth Guest

    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 =
    search.GetDirectoryEntry.Properties.Item("Department").Value
    Else
    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 asp.net 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.
    zifth, Dec 14, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    5
    Views:
    26,423
    Mike Schilling
    Mar 29, 2006
  2. J.Ram
    Replies:
    7
    Views:
    635
  3. Pavel
    Replies:
    7
    Views:
    503
    Pavel
    Sep 19, 2010
  4. ejcosta
    Replies:
    2
    Views:
    843
    Eurico Costa
    Oct 8, 2004
  5. Michael Tan
    Replies:
    32
    Views:
    906
    Ara.T.Howard
    Jul 21, 2005
Loading...

Share This Page