Active Directory Groups

bellemmar

Registered User.
Local time
Today, 03:41
Joined
Mar 9, 2011
Messages
64
I'm trying to make a database read only except to a certain group of users using Active Directory. The group that should have full access to the database is called Policy. I have the following code:

Private Sub Form_Open(Cancel As Integer)
Dim blnHasAccess As Boolean
Dim strGroupWithReadWriteAccess As String

strGroupWithReadWriteAccess = "Policy"

blnHasAccess = IsMemberOfSecurityGroups(strGroupWithReadWriteAccess)
Me.AllowAdditions = blnHasAccess
Me.AllowDeletions = blnHasAccess
Me.AllowEdits = blnHasAccess
End Sub

It isn't working. Active Directory is new to me. Any help would be appreciated.
 
Yes, this is the article I initially used but the code isn't working and I can't figure out why. The first line of the code is an error somehow; comes up highlighted.
 
Howzit

Probably nothing but has it got anything to do wth the space?

Code:
blnHasAccess = IsMemberOfSecurityGroups(strGroupWithReadWriteAcc[B]e ss)[/B]
 
What line exactly? Not the Dim line I assume. Did you copy in the modules?
 
I went into the form itself and pasted the code there. But when I try to open the form, I get Compile Error: Sub or Function not defined and then the first line of the code highlights in yellow and IsMemberOfSecurityGroups highlights in blue.
 
Howzit

Did you look into the space issue on this line - see my first post.
 
Sorry, meant to comment on that, yes, fixed the space but still having the same issue.
 
Howzit

I don't know much about active directory as well so probably will not be of much help. Just to confirm that you do have a Public Function called IsMemberOfSecurityGroups sitting in a module somewhere?
 
If the Function IsMemberOfSecurityGroups is not in the forms module don't you need to add basXXXXX.IsMemberOfSecurityGroups(arguments) - or it will give the described error?
 
This line:
Code:
blnHasAccess = IsMemberOfSecurityGroups(strGroupWithReadWriteAccess)
Is a call to a function that is doing the "talking" to Active Directory. Your error message suggests that this function doesn't exist.

The function should contain something along the lines of (sample script copy and pasted from elsewhere just to illustrate something talking to Active Directory around group membership):

Code:
Set objUser = GetObject _ 
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com") 
  
intPrimaryGroupID = objUser.Get("primaryGroupID") 
arrMemberOf = objUser.GetEx("memberOf") 
  
    debug.print "Member of: "
 
    For Each Group in arrMemberOf 

        debug.print Group 

    Next

Nothing in the supplied code example is doing anything with Active Directory.
 

Users who are viewing this thread

Back
Top Bottom