473,320 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Active Directory groups lookup

14
I'm trying to develop a page which will grab a few details for the currently logged-in Windows user from the Active Directory controller.

I can get the full name of the user from their username without any problems.

What I can't do is find out which groups the user belongs to. The end result will hopefully be a method to ascertain whether the current user is a member of the 'mod' group, the 'admin' group, or neither.

I've tried a few different things, but I just can't find the lookup query for it. Most of the sites I've found so far seem to be aimed at ASP.NET, but my directory/database access skills really aren't good enough to understand what they're doing, why they're doing it, or how to port it back to Classic ASP.

Here's the current code (slightly modified).

Expand|Select|Wrap|Line Numbers
  1. Dim adoCommand, conn, adoRecordSet, currentUser
  2.  
  3. currentUser = Request.ServerVariables("LOGON_USER")
  4.  
  5. Set conn = Server.CreateObject("ADODB.Connection")
  6. conn.Provider = "ADsDSOObject"
  7. conn.Properties("User ID") = "xxx"
  8. conn.Properties("Password") = "yyy"
  9. conn.Properties("Encrypt Password") = True
  10. conn.Open
  11.  
  12. Set adoCommand = Server.CreateObject("ADODB.Command")
  13. adoCommand.ActiveConnection = conn
  14. adoCommand.CommandText = "SELECT cn FROM 'LDAP://ou=USERS,ou=PRNTEST,dc=domain,dc=extension' WHERE ObjectClass='User' AND sAMAccountName='" & currentUser & "' ORDER By cn"
  15.  
  16. Set adoRecordSet = adoCommand.Execute
  17.  
  18. Session("currentUser") = adoRecordSet(0)
I know there are a few different methods to access the Active Directory, but this was the one I understood the most, having done a tiny bit of MySQL.

Some of the sites I've seen seem to imply there is a 'memberof' attribute of the user record, but the entire query above (SELECT * FROM) doesn't show anything like that, just the hierarchy of OUs to the CN.

So, how should I go about checking the AD group memberships for a given user? Is the SQL-type query going to work, or do I need to try a different approach?

Thanks in advance.
Sep 24 '08 #1
0 2375

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Henning Kristensen | last post by:
Hi I need a little help with some VB.Net code.. I am pulling my computer's GUID out using WMI Dim wmiObj As New System.Management.ManagementObjectSearcher("SELECT UUID FROM...
0
by: Henning Kristensen | last post by:
Hi I need a little help with some VB.Net code.. I am pulling my computer's GUID out using WMI Dim wmiObj As New System.Management.ManagementObjectSearcher("SELECT UUID FROM...
0
by: Yaseen D M | last post by:
I am list groups of a user from active directory. I get the list but if i remove the user from one of the groups and again list the groups it still includes the groups from the the user was...
5
by: David W. Fenton | last post by:
Does anyone know of any Windows API calls to get to Active Directory organizational unit information? I searched for this a while back and found nothing. It would be a great thing if I could get to...
4
by: CodeRazor | last post by:
I need to retrieve a list of groups from Active Directory. Then i need to retrieve a list of users from a group. I'm unfamiliar with Active Directory objects. Can i connect to Active Directory...
1
by: tangus via DotNetMonster.com | last post by:
Hello all, I'm really struggling with getting some Active Directory code to work in ASP.NET. Can you please provide assistance? I am executing the following code: Dim enTry As DirectoryEntry =...
4
by: Patirck Ige | last post by:
Would it be easier to have an intranetsystem built based on some security gruopson Active directory or having to use a Database to have a validation store and Roles. Which way would be the best to...
4
by: Patrick.O.Ige | last post by:
If i want to generate a menu structure depending on who is logged in in an intranet system(using windows authentication) is it better to use the GROUPS in Active Directory or to move the Active...
0
by: bcanter | last post by:
I found a file on the web that will allow you to enumerate groups but it was an .hta and the top level admins won't allow this. I need to give managers access to the groups so that when a new user is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.