Solved

Can MS Access query Active Directory?

Posted on 2007-03-19
11
8,669 Views
Last Modified: 2013-11-27
Hi All,

I am developing an Access 2003 application. The application runs from XP clients in a Windows 2003 domain environment. The app is broken into Front-end mde (XP clients) and the Back-end mdb (server).

The app is driven from a main menu bar. On this menu bar is a Maintenance Menu option. I want to control which users can use the Maintenance Menu by determining if the Active Directory logon account, which they logged onto the XP client with, is a member of a certain Active Directory group.

Can I do this in access?.

Thanks in Advance
Mick
0
Comment
Question by:ReefIT
  • 4
  • 4
  • 2
11 Comments
 
LVL 4

Accepted Solution

by:
psychakias2 earned 250 total points
ID: 18753311
Function IsMember(strDomain As String, strGroup _
   As String, strMember As String) As Boolean
  Dim grp As Object
  Dim strPath As String
 
  strPath = "WinNT://" & strDomain & "/"
  Set grp = GetObject(strPath & strGroup & ",group")
  IsMember = grp.IsMember(strPath & strMember)
End Function


And use it like this:
IsMember("YourDomain", "Administrators", "Name")
0
 
LVL 67

Assisted Solution

by:sirbounty
sirbounty earned 250 total points
ID: 18753313
Try adding this...

Dim si
Set si=CreateObject("ADSystemInfo")
strAdsPath=si.UserName
objUser=GetObject("LDAP://" & strAdsPath)
strUser=objUser.CN
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18753326
Missed a piece..

Dim si
Set si=CreateObject("ADSystemInfo")
strAdsPath=si.UserName
objUser=GetObject("LDAP://" & strAdsPath)
strUser=objUser.CN
strMember=Filter(objUser.MemberOf, "YourGroup")
If ubound(strMember) >= 0 Then
' User is a member of YourGroup
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 1

Author Comment

by:ReefIT
ID: 18754008
How do I determine the user name of the currenty logged on user account?.

Thanks
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18754015
This line, strUser=objUser.CN, should report the user name...
0
 
LVL 1

Author Comment

by:ReefIT
ID: 18754469
I get 'wrong number of arguments or invalid property assignment' error on this line:

strMember=Filter(objUser.MemberOf, "YourGroup")
0
 
LVL 4

Expert Comment

by:psychakias2
ID: 18756106
Simply use the function I mentioned in my first post like this:

IsMember("YourDomain", "Administrators", Environ$("Username"))

Just replace "YourDomain" by the domain name that you have, and "Administrators" by the group that you want to look in.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18756283
Is it likely that the user is not a member of a group, or a member of only one?

You can test for it using

If isArray(objUser.MemberOf) Then
   strMember=Filter(objUser.MemberOf, "YourGroup")
Else
   'Not a member or member of only one group
0
 
LVL 1

Author Comment

by:ReefIT
ID: 18834641
The following worked for me.

'Not all users of DIS can access the tool menu.
'This function finds out what Active Directory user account the user has logged onto the
'client PC with. It then checks to see if the account is a member of an AD group named through the
'constToolsMenuGroupName. If the account is a member, the menu is available.
    Dim objToolsMenuGroup As Object
    Dim strPath As String
    Dim blnIsMember As Boolean
    Dim objADSystemInfo As Object
    Dim arDomainDNSName() As String
       
    'Get a reference to the ADSystemInfo ActiveX object.
    Set objADSystemInfo = CreateObject("ADSystemInfo")
   
    ' Get the NetBios name of the Domain. DomainDNSName returns eg. 'reefit.local'.
    ' The split function returns 'reefit' and 'local'.
    arDomainDNSName = Split(objADSystemInfo.DomainDNSName, ".")
   
    ' arDomainDNSName(0) the netbios name. eg. 'reefit'.
    strPath = "WinNT://" & arDomainDNSName(0) & "/"
    'Get a reference to the Tools menu group.
    Set objToolsMenuGroup = GetObject(strPath & constToolsMenuGroupName & ",group")
    'Determine the AD username, and then see if it is a member of the group.
    blnIsMember = objToolsMenuGroup.IsMember(strPath & Environ$("Username"))
   
    If blnIsMember Then
        'Allow the menu to expand as normal.
    Else
        ' User account doesn't have permission to use the menu.
        ' Displaying a msgbox also stops the menu from expanding.
        MsgBox "You don't have persmission to use the Tools Menu!.", vbInformation + vbOKOnly, "Tools Menu Unavailable"
    End If
0
 
LVL 1

Author Comment

by:ReefIT
ID: 18834650
Sorry... I meant to split that between the both of you.
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question