<% ADsDomain = Session("ADsDomain") 'Session may time out If ADsDomain = "" then ADsDomain = Application("ADsDomain") End if userName = Request.Form("userName") Set con = CreateObject("ADODB.Connection") Set com = CreateObject("ADODB.Command") domainPath = "LDAP://" & ADsDomain 'Open the ADSI Connection. con.Provider = "ADsDSOObject" 'Credentials con.Properties("User ID") = Application("UserID") con.Properties("Password") = Application("Password") con.Open "Active Directory Provider" Set Com.ActiveConnection = con Com.CommandText = "<" & domainPath & ">;(&(anr=" & userName & ")(|(objectCategory=organizationalPerson)(objectCategory=group)));ADsPath,name,telephoneNumber,title,physicalDeliveryOfficeName,department,objectCategory;subtree" Com.Properties("Page Size") = 64 Com.Properties("Timeout") = 30 'seconds Com.Properties("Cache Results") = False %>

banner.gif (3494 bytes)         search.gif (1222 bytes)

Search for:   <% Response.Write userName%>    

<% '--- TIME BEGIN t = Timer Set rs = Com.Execute elapse = Timer - t '--- TIME END On Error Resume Next counter = 0 %> <% While Not rs.EOF %> <% rs.MoveNext Wend %>

Name

Phone

Title

Office

Department

<% 'Increment the counter counter = counter + 1 'Alternate background color for enhancing the appearance md = counter mod 2 if ( md = 0 ) then bkColor = "#C9C9C9" else bkColor = "#E8E8E8" end if '-- Find the object category sCat = rs.Fields("objectCategory").Value idx = InStr( 1, sCat, "=Person" ) if ( idx > 0 ) then bPerson = True else bPerson = False end if %>
"><% Response.Write rs.Fields("Name").Value %> <% if ( bPerson )then Response.Write rs.Fields("telephoneNumber").Value else Response.Write "(Group)" end if %> <% Response.Write rs.Fields("title").Value %> <% Response.Write rs.Fields("physicalDeliveryOfficeName").Value %> <% Response.Write rs.Fields("department").Value %>
<% if ( counter > 0 ) then Response.Write counter & " object(s) found" else Response.Write "No object is found" end if Set con = nothing Set com = nothing %>

<% Response.Write "Query was executed in: " & elapse & " second(s)" Response.Write "
" elapse = Timer - t Response.Write "Total Time (Execute, Enumeration and Rendering): " & elapse & " second(s)" %>