Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Multiple active directory groups access to ms access form

Posted on 2012-08-16
3
Medium Priority
?
901 Views
Last Modified: 2012-08-17
I have the following code working in my ms access form (ms access 2007) with active directory users. Members in the purchase group have access.

But I need to know a code where multiple groups have access to this form. So if you are member of Sec-Purchase or Sec-Management.

Who knows how I can do this?

Here's my code:

  Private Sub Form_Open(Cancel As Integer)
    Dim strGroupWithAccess As String
   
   
    'Set the name of the group with access to this form.
    strGroupWithAccess = "Sec-Purchase"

   
    'Test if the user has access. If not, set Cancel to True and the form will not open.
    Cancel = Not IsMemberOfSecurityGroups(strGroupWithAccess)
   
    If Cancel = True Then
        MsgBox "You have no access to this form.", vbExclamation
    End If

End Sub


It's driving me crazy! I've tried a lot of options but my vb knowledge is limited...

Thanks a lot for helping me out!
Kind regards,
Michiel
0
Comment
Question by:mvdwal
3 Comments
 
LVL 85
ID: 38303932
Just check for each group:

 Cancel = Not IsMemberOfSecurityGroups(strGroupWithAccess) OR Not IsMemberOfSecurityGroup(YourOtherGroup) OR Not IsMemberOfSecurityGroup(YourNextGroup)

If that doesn't work, you can always do this:

 Cancel = Not IsMemberOfSecurityGroups(strGroupWithAccess)

If Not Cancel Then
  Cancel = Not IsMemberOfSecurityGroups(YourNextGroup)
End If
0
 
LVL 77

Accepted Solution

by:
peter57r earned 2000 total points
ID: 38303959
You can build a more general procedure like this...(original code no longer required commented out)

Private Sub Form_Open(Cancel As Integer)
'store a list of groups with access to form in an array and test if user is in any of them

             ' Dim strGroupWithAccess As String
    Dim x as integer, OK as Boolean
    Dim OKArray(1)         ' set number of groups, base 0

' define array of groups with access
    OKArray(0)= "Sec-Purchase"
    OKArray(1)= "Sec-Management"  
   
            ' 'Set the name of the group with access to this form.
             ' strGroupWithAccess = "Sec-Purchase"
 OK = false
   for x = 0 to 1   ' loop through array; if any is allowed then OK = true
       OK =  IsMemberOfSecurityGroups(okarray(x))   or OK
   Next x
   
           'Test if the user has access. If not, set Cancel to True and the form will not open.
            'Cancel = Not IsMemberOfSecurityGroups(strGroupWithAccess)

  Cancel = not OK
   
    If Cancel = True Then
        MsgBox "You have no access to this form.", vbExclamation
    End If

End Sub
0
 

Author Closing Comment

by:mvdwal
ID: 38304102
Dear Peter,

Thanks a lot! It works!!!

I was spending hours on this form...
I did not check the other solution. But also many thanks for helping me out on this.

Do you have any tips to understand vb better? Maybe a good book? I wanna learn this!
Kind regards,
Michiel
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
A bad practice commonly found during an account life cycle is to set its password to an initial, insecure password. The Password Reset Tool was developed to make the password reset process easier and more secure.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Suggested Courses

810 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