Advertisement
Guest User

AD calls

a guest
Jul 9th, 2017
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <%@ Language=VBScript %>
  2. <%
  3. Set objConn = Server.CreateObject("ADODB.Connection")
  4. objConn.provider ="ADsDSOObject"
  5. objConn.Properties("User ID") = "acc"
  6. objConn.Properties("Password") = "pass"
  7. objConn.Properties("Encrypt Password") = True
  8. objConn.open "Active Directory Provider"
  9. Set objCom = CreateObject("ADODB.Command")
  10. Set objCom.ActiveConnection = objConn
  11. objCom.CommandText ="select sAMAccountName,givenname,sn,extensionAttribute1,ipPhone,mail,telephonenumber,mobile,thumbnailphoto " & _
  12.     " FROM 'LDAP://OU=...DC=net' where " & _
  13.     "userAccountControl=512 AND sAMAccountname='*' AND extensionAttribute1='*' ORDER by extensionAttribute1"
  14. Set objRS = objCom.Execute(sn)
  15.  
  16. res = "["
  17. Do While Not objRS.EOF Or objRS.BOF
  18.     ph = "false"
  19.     if not isnull(objRS("thumbnailphoto")) then ph = "true"
  20.     if right(res, 1) <> "[" then res = res & ","
  21.     res = res & "{""desk"":""" & objRS("extensionAttribute1") & """, ""user"":""" & objRS("sAMAccountName") & """, ""firstname"":""" & objRS("givenname") & """, " & _
  22.         """surname"":""" & objRS("sn") & """, ""extension"":""" & objRS("ipPhone") & """, ""email"":""" & objRS("mail") & """, ""mobile"":""" & objRS("mobile") & """, ""photo"":" & ph & " }"
  23.     objRS.MoveNext
  24. Loop
  25. res = res & "]"
  26. Response.Write res
  27. Response.Flush
  28.  
  29. objRS.Close
  30. objConn.Close
  31. Set objRS = Nothing
  32. Set objConn = Nothing
  33. Set objCom = Nothing
  34. Set objADsPath = Nothing
  35. Set objDomain = Nothing
  36. %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement