?
Solved

Can MS Access query Active Directory?

Posted on 2007-03-19
11
Medium Priority
?
8,700 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
11 Comments
 
LVL 4

Accepted Solution

by:
psychakias2 earned 750 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 750 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
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…

765 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