home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / ADSDK.ZIP / Samples / ASP / WAB / search.vbs < prev   
Encoding:
Text File  |  1999-02-19  |  1.6 KB  |  72 lines

  1.  
  2.  
  3.    
  4.    Set oArgs = wscript.Arguments
  5.    wscript.echo oArgs(0)
  6.    If (oArgs.Count < 1) Then
  7.         WScript.Echo "usage: search name"
  8.         '"where name can be alias, first/last name, group name"
  9.         WScript.Quit(1)
  10.    end if 
  11.  
  12.   if ( oArgs.Count = 2 ) then
  13.     ADsDomain = oArgs(1)
  14.   else
  15.     ADsDomain = "ntdev.microsoft.com"
  16.   end if 
  17.  
  18.   
  19.  
  20.   
  21.   userName = oArgs(0)
  22.  
  23.  
  24.   Set con = CreateObject("ADODB.Connection")
  25.   Set com =   CreateObject("ADODB.Command")
  26.   domainPath = "LDAP://" & ADsDomain
  27.     
  28.   'Open the ADSI Connection.
  29.   con.Provider = "ADsDSOObject"
  30.  
  31.   'Credentials  
  32.    con.Properties("User ID") = "NTDEV\ntdev"
  33.    con.Properties("Password") = "ntdevntdev"
  34.  
  35.    con.Open "Active Directory Provider"
  36.    Set Com.ActiveConnection = con
  37.  
  38.  
  39.  
  40.    
  41.    Com.CommandText = "<" & domainPath & ">;(&(anr=" & userName & ")(|(objectCategory=organizationalPerson)(objectCategory=group)));ADsPath,name,telephoneNumber,title,physicalDeliveryOfficeName,department,objectCategory;subtree"
  42.  
  43.    Com.Properties("Page Size") = 64
  44.    Com.Properties("Timeout") = 30 'seconds
  45.    
  46.       
  47.  
  48.  
  49.  
  50.  
  51.    '--- TIME BEGIN
  52.    wscript.echo "Searching..."
  53.    t = Timer
  54.    Set rs = Com.Execute
  55.    elapse = Mid(CStr(Timer - t),1,5)
  56.    '--- TIME END
  57.    On Error Resume Next
  58.    counter = 0
  59.  
  60.  
  61.  
  62. While Not rs.EOF
  63.  
  64.      'Increment the counter 
  65.      counter = counter + 1 
  66.      'Alternate background color for enhancing the appearance 
  67.       wscript.echo rs.Fields("name")
  68.      rs.MoveNext
  69. Wend
  70.  
  71.    wscript.echo "Query was executed in: " & elapse & " second(s)"
  72.