473,545 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Active Directory groups lookup

14 New Member
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 2398

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

Similar topics

1
634
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 Win32_ComputerSystemProduct" Dim objMgmt As System.Management.ManagementObjec Dim MyByteGuid As Byte( Dim MyStringGuid As Strin Dim MyGuid As Gui For Each objMgmt In...
0
352
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 Win32_ComputerSystemProduct" Dim objMgmt As System.Management.ManagementObjec Dim MyByteGuid As Byte( Dim MyStringGuid As Strin Dim MyGuid As Gui For Each objMgmt In...
0
2499
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 actually removed. When i check in active directory user is deleted from that group. Does DirectoryEntry and DirectorySearcher objects cache the active...
5
3850
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 it, as it would mean I wouldn't have to duplicate location information in Access/Jet security for a certain application I'm managing. Any ideas?...
4
12168
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 with LDAP, without specifying a particular group? How can i retrieve a list of groups? thank you, -- i'm looking for any pointers.
1
3879
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 = New DirectoryEntry("LDAP://domain") Dim mySearcher As New DirectorySearcher(enTry) Dim resEnt As SearchResult mySearcher.Filter =...
4
1382
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 go?
4
2339
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 Directory groups into a Sql Server database and base the authrorization and authentication on the SQL Server roles/groups? Whats the best way to make...
0
2492
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 created they can tell me who they want their account to be modeled after. The html app works great as a .hta file but when it is saved as a web page...
0
7410
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7668
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7437
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5984
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5343
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4960
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3466
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1901
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
722
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.