Is there a way to Retrieve Current Group?

  • Thread starter Thread starter IM
  • Start date Start date
I

IM

Is there a way to get the group of the current user (similar to the
currentuser() function) ?
Thanks,
IzM
 
A user can be (and most often is) a member of more than one group
so what we usually do is to check to see if a user is a member of
a *specific* group we want to check.

Here is a past post of mine on this subject:

There is code for this in the Security FAQ:

Security FAQ (the Security Bible):
http://support.microsoft.com/?kbid=207793
More specifically:
http://support.microsoft.com/default.aspx?scid=/support/access/content/secfaq.asp#_Toc493299691

Here is also some code posted by MVP Albert Kallal:

The following module is created:
+++++++++++++++++++++++++++++++++++++++++++++
Public Function IsInGroup(UsrName As String, GrpName As String) As Boolean
'Determines whether UsrName is a member of GrpName
'--
'http://www.attcanada.net/~kallal.msn/RidesSec/index.html
'--Dec 16th 2002 microsoft.public.access.security
'Albert D.kallal

Dim grp As DAO.Group
Dim IIG As Boolean
Dim usr As DAO.User
IIG = False

For Each usr In DBEngine.Workspaces(0).Users
If usr.name = UsrName Then GoTo FoundUser
Next

GoTo IIG_Exit

FoundUser:

For Each grp In usr.Groups
If grp.name = GrpName Then IIG = True
Next

IIG_Exit:
IsInGroup = IIG

End Function
+++++++++++++++++++++++++++++++++++++++++++++

And the code for checking goes like this:

If (IsInGroup(CurrentUser(), "NameOfGroupHere") = True) Then
' Execute Code
Else
' Execute different code
End If

Hope that helps,
--
Jeff Conrad
Access Junkie - MVP
http://home.bendbroadband.com/conradsystems/accessjunkie.html
http://www.access.qbuilt.com/html/articles.html

in message:
 
Thanks for your help!!!
IzM

Jeff Conrad said:
A user can be (and most often is) a member of more than one group
so what we usually do is to check to see if a user is a member of
a *specific* group we want to check.

Here is a past post of mine on this subject:

There is code for this in the Security FAQ:

Security FAQ (the Security Bible):
http://support.microsoft.com/?kbid=207793
More specifically:
http://support.microsoft.com/default.aspx?scid=/support/access/content/secfaq.asp#_Toc493299691

Here is also some code posted by MVP Albert Kallal:

The following module is created:
+++++++++++++++++++++++++++++++++++++++++++++
Public Function IsInGroup(UsrName As String, GrpName As String) As Boolean
'Determines whether UsrName is a member of GrpName
'--
'http://www.attcanada.net/~kallal.msn/RidesSec/index.html
'--Dec 16th 2002 microsoft.public.access.security
'Albert D.kallal

Dim grp As DAO.Group
Dim IIG As Boolean
Dim usr As DAO.User
IIG = False

For Each usr In DBEngine.Workspaces(0).Users
If usr.name = UsrName Then GoTo FoundUser
Next

GoTo IIG_Exit

FoundUser:

For Each grp In usr.Groups
If grp.name = GrpName Then IIG = True
Next

IIG_Exit:
IsInGroup = IIG

End Function
+++++++++++++++++++++++++++++++++++++++++++++

And the code for checking goes like this:

If (IsInGroup(CurrentUser(), "NameOfGroupHere") = True) Then
' Execute Code
Else
' Execute different code
End If

Hope that helps,
--
Jeff Conrad
Access Junkie - MVP
http://home.bendbroadband.com/conradsystems/accessjunkie.html
http://www.access.qbuilt.com/html/articles.html

in message:
 
Back
Top