+ Post New Thread
Results 1 to 11 of 11
MIS Systems Thread, asp and active directory in Technical; Hello All, I need to know how I can get list of groups for one user from AD by using ...
  1. #1
    acee_ad's Avatar
    Join Date
    Oct 2012
    Posts
    5
    Thank Post
    2
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    asp and active directory

    Hello All,

    I need to know how I can get list of groups for one user from AD by using ASP??

    Thanks,
    ACE

  2. #2

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    11,223
    Thank Post
    874
    Thanked 2,717 Times in 2,302 Posts
    Blog Entries
    11
    Rep Power
    780

  3. Thanks to SYNACK from:

    acee_ad (23rd October 2012)

  4. #3
    acee_ad's Avatar
    Join Date
    Oct 2012
    Posts
    5
    Thank Post
    2
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    <%@ LANGUAGE=VBSCRIPT %>
    <%Option Explicit%>
    <%
    dim user
    user=Request.ServerVariables("LOGON_USER")
    Session("user")=user
    'response.write(user)
    Function getADUserInfo(strUID)
    on error resume next
    strGeneralLookupError = false
    strBase = "<LDAP://DC=school, DC=com>"
    strFilter = "(sAMAccountName=" & strUID & ")"
    strAttributes = "cn, mail, company, givenName, sn, ADsPath, name, sAMAccountName, telephoneNumber, employeeid, extensionattribute15, displayname, distinguishedName, memberOf"
    'strAttributes = "cn, company, givenName, sn, ADsPath, name, sAMAccountName, telephoneNumber"
    strScope = "subtree"
    strFullCommand = strBase & ";" & strFilter & ";" & strAttributes & ";" & strScope
    set rsADUserInfo = Server.CreateObject("ADODB.Recordset")
    set rsADUserInfo = connAD.Execute(strFullCommand)
    if err.number <> 0 then
    strGeneralLookupError = true
    end if
    set getADUserInfo = rsADUserInfo
    set rsADUserInfo = Nothing
    End Function






    Sub getUserData(p_strUserID)
    on error resume next
    set rsUserData = Server.CreateObject("ADODB.Recordset")
    set rsUserData = getADUserInfo(p_strUserID)
    if not rsUserData.EOF then
    Session("name") = rsUserData("displayname")
    'strUserSN = rsUserData("sn")
    'strUserOU = rsUserData("company")
    'strUserEmail = rsUserData("mail")
    session("group") = rsUserData("distinguishedName")
    session("passuser") = rsUserData("memberOf")
    else
    strADLookupSuccess = false
    end if
    rsUserData.Close
    set rsUserData = Nothing
    End Sub




    on error resume next


    response.expires = 0


    DIM connAD, rsUserData, rsADUserInfo
    DIM strUserGN, strUserSN, strUserOU, strUserEmail, strUserPhone, test
    DIM strBase, strFilter,strAttributes, strScope, strFullCommand
    DIM strGeneralLookupError, strADLookupSuccess
    DIM strUserID


    strUserGN = "The user can not be found in the system."
    strGeneralLookupError = false
    strADLookupSuccess = true


    set connAD = Server.CreateObject("ADODB.Connection")
    connAD.Provider = "ADsDSOObject"
    connAD.Properties("User ID") = "school\adminuser" ' ### remember to make sure this user has rights to access AD
    connAD.Properties("Password") = "*******"
    connAD.Properties("Encrypt Password") = true
    connAD.Open


    strUserID = "user"
    call getUserData(strUserID)


    connAD.Close
    set connAD = Nothing


    response.write("Name: "&Session("name")&"<br/>")
    response.write("Pass Username: "&Session("passuser")&"<br/>")
    response.write("Group: "&Session("group")&"<br/>")








    %>


    I have this code for ASP and I can not see the groups of this user any help please??

    Thanks,
    ACE

  5. #4

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    11,223
    Thank Post
    874
    Thanked 2,717 Times in 2,302 Posts
    Blog Entries
    11
    Rep Power
    780
    What is your internal DNS domain name, School.com, you need to make sure your search path it right, the easiest way is to look at your AD using ADSI Edit on a server (just be sure not to change anything) this will give you the LDAP search path.

  6. #5
    acee_ad's Avatar
    Join Date
    Oct 2012
    Posts
    5
    Thank Post
    2
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    I can see any thinks like cn, mail, company, givenName, sn, ADsPath, name, sAMAccountName, telephoneNumber, employeeid, extensionattribute15, displayname, distinguishedName .....
    only memberof because the users have
    multi groups

  7. #6

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    11,223
    Thank Post
    874
    Thanked 2,717 Times in 2,302 Posts
    Blog Entries
    11
    Rep Power
    780
    You probably want the ADsPath of the OU that your users/groups are in then it should connect and find it.

  8. #7
    acee_ad's Avatar
    Join Date
    Oct 2012
    Posts
    5
    Thank Post
    2
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    ADsPath it is for User OU not for user group

  9. #8

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    11,223
    Thank Post
    874
    Thanked 2,717 Times in 2,302 Posts
    Blog Entries
    11
    Rep Power
    780
    Quote Originally Posted by acee_ad View Post
    ADsPath it is for User OU not for user group
    You should be able to go higher to the first folder/OU that contains both and then that is your strBase search path.

  10. #9
    acee_ad's Avatar
    Join Date
    Oct 2012
    Posts
    5
    Thank Post
    2
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    By example I am ace i am in 4 groups: IT Groups, Admin group, Programmer Group , and domain admins group I need to get those groups by using asp not only for me for all staff and students

  11. #10

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    11,223
    Thank Post
    874
    Thanked 2,717 Times in 2,302 Posts
    Blog Entries
    11
    Rep Power
    780
    This tool will probably help:
    ADSI Scriptomatic

    It helps you generate ADSI calls in VBS which you can then just copy and paste into ASP to a large extent.

  12. #11

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    11,223
    Thank Post
    874
    Thanked 2,717 Times in 2,302 Posts
    Blog Entries
    11
    Rep Power
    780
    This should generate it for a single user:
    Script List the Active Directory Groups a User Belongs To

  13. Thanks to SYNACK from:

    acee_ad (23rd October 2012)

SHARE:
+ Post New Thread

Similar Threads

  1. PDA and Active Directory
    By localzuk in forum Windows
    Replies: 4
    Last Post: 10th October 2007, 03:54 PM
  2. Terrastation and active directory
    By edie209 in forum Windows
    Replies: 8
    Last Post: 27th September 2007, 02:46 PM
  3. TeraStation and Active Directory
    By mmoseley in forum Hardware
    Replies: 4
    Last Post: 6th September 2007, 01:28 PM
  4. Exchange Server 2007 and Active Directory
    By MarkB in forum Windows
    Replies: 7
    Last Post: 16th April 2007, 10:53 AM
  5. Wireless bridgeing and Active directory replication
    By HodgeHi in forum Wireless Networks
    Replies: 5
    Last Post: 7th February 2007, 12:12 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •