Active Directory- extracting groups

Reply

Join Date: May 2007
Posts: 19
Reputation: Cruize_Invades is an unknown quantity at this point 
Solved Threads: 1
Cruize_Invades's Avatar
Cruize_Invades Cruize_Invades is offline Offline
Newbie Poster

Active Directory- extracting groups

 
0
  #1
19 Days Ago
Hello!

I am currently doing some authentication in Active Directory.
Our AD is running in Windows 2008 Server and I manage to log-in based in our AD. However I also want to get the group where the user belongs. but I don't know how. Can anyone help me?

here is the authentication in AD I copied...

  1. <%@ Language="VBScript" %>
  2. <%
  3.  
  4. Option Explicit
  5. Response.Buffer = True
  6.  
  7. '// 1. Form Validation
  8. Dim Submit, UserName, Password, Domain, Result, Message
  9. Submit = "Authenticate"
  10.  
  11. 'Assume Failure
  12. Application("Error")= true
  13.  
  14. If Submit = "Authenticate" Then
  15. response.write("autenthication <br>")
  16. 'Get the input from your HTML form
  17. UserName = Request.Form("UserName")
  18. Password = Request.Form("Password")
  19. Domain = Application("Domain")
  20.  
  21. Session("usern") = UserName
  22. 'Call the AuthenticateUser() function to do the verification process
  23. Result = AuthenticateUser(UserName, Password, Domain)
  24.  
  25. If Result Then
  26. 'If user exist, then redirect to success page
  27. 'login success
  28. Application("Error")= false
  29. Response.Redirect ("success.asp")
  30. Else
  31. 'If user don't exist, redirect to error page
  32. 'login failed
  33. Application("Error")= true
  34. Response.Redirect ("../")
  35. End If
  36. End If
  37.  
  38. '// 2. Authenticate Function
  39. Function AuthenticateUser(UserName, Password, Domain)
  40. Dim strUser, strPassword, strQuery, oConn, cmd, oRS
  41.  
  42. 'Assume Failure
  43. AuthenticateUser = false
  44.  
  45. strQuery = "SELECT cn FROM 'LDAP://" & Domain & "' WHERE objectClass='*'"
  46. Set oConn = server.CreateObject("ADODB.Connection")
  47. oConn.Provider = "ADsDSOOBJECT"
  48. oConn.Properties("User ID") = UserName
  49. oConn.Properties("Password") = Password
  50. oConn.Properties("Groups") = "SALES"
  51. oConn.Properties("Encrypt Password") = true
  52. oConn.open "ADProvider", strUser, strPassword
  53. Set cmd = server.CreateObject("ADODB.Command")
  54. Set cmd.ActiveConnection = oConn
  55. cmd.CommandText = strQuery
  56.  
  57. On Error Resume Next
  58. Set oRS = cmd.Execute
  59.  
  60. If oRS.bof OR oRS.eof Then
  61. AuthenticateUser = False
  62. Else
  63. AuthenticateUser = True
  64. End if
  65.  
  66. Set oRS = Nothing
  67. Set oConn = nothing
  68. End Function
  69. '############### CHECKER #########
  70.  
  71. response.write(myString)
  72.  
  73.  
  74. %>
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC