[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Can MS Access query Active Directory?

Posted on 2007-03-19
11
Medium Priority
?
8,716 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
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…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

649 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