Active Directory Groups (1 Viewer)

bellemmar

Registered User.
Local time
Today, 05:17
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.
 

bellemmar

Registered User.
Local time
Today, 05:17
Joined
Mar 9, 2011
Messages
64
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.
 

Kiwiman

Registered User
Local time
Today, 13:17
Joined
Apr 27, 2008
Messages
799
Howzit

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

Code:
blnHasAccess = IsMemberOfSecurityGroups(strGroupWithReadWriteAcc[B]e ss)[/B]
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 05:17
Joined
Aug 30, 2003
Messages
36,134
What line exactly? Not the Dim line I assume. Did you copy in the modules?
 

bellemmar

Registered User.
Local time
Today, 05:17
Joined
Mar 9, 2011
Messages
64
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.
 

Kiwiman

Registered User
Local time
Today, 13:17
Joined
Apr 27, 2008
Messages
799
Howzit

Did you look into the space issue on this line - see my first post.
 

bellemmar

Registered User.
Local time
Today, 05:17
Joined
Mar 9, 2011
Messages
64
Sorry, meant to comment on that, yes, fixed the space but still having the same issue.
 

Kiwiman

Registered User
Local time
Today, 13:17
Joined
Apr 27, 2008
Messages
799
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?
 

Rank Am

Registered User.
Local time
Today, 20:17
Joined
Apr 30, 2005
Messages
68
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?
 

tehNellie

Registered User.
Local time
Today, 13:17
Joined
Apr 3, 2007
Messages
751
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

Top Bottom