Capture "Groups"

mcgilla

Registered User.
Local time
Today, 11:21
Joined
Sep 17, 2010
Messages
31
is there a way to capture the domain groups that a user is a member of?

For example, if I had someone setup groups like the following

CompanyPurchasing
CompanyProduction
CompanyAccounting

and I was a member of two of those, can I somehow retreive that information in access to allow some of the functionality of a database, but restrict it from others. Handling the funcationality at this point isn't much of an issue, at least for now, I'm controlling some of this by the environ("username") method. But I'm looking for groups to allow several people access.

Thanks
Ed
 
You can use the following method to check the Current User's Group:

Code:
Public Function FindGroup()
Dim grpItem, wsp As Workspace
Set wsp = DBEngine.Workspaces(0)
For Each grpItem In wsp.Users(CurrentUser).Groups
    Select Case grpItem.Name
          Case "CompanyPurchasing"
              'Action Code
          Case "CompanyProduction"
              'Action Code
          Case "CompanyAccounting"
              'Action Code
    End Select
Next

End Function

Your database must be implemented with Microsoft Access Security.


The Environ("username") will fetch you the Windows Login ID not MS-Access UserName.
 
You can use the following method to check the Current User's Group:

Code:
Public Function FindGroup()
Dim grpItem, wsp As Workspace
Set wsp = DBEngine.Workspaces(0)
For Each grpItem In wsp.Users(CurrentUser).Groups
    Select Case grpItem.Name
          Case "CompanyPurchasing"
              'Action Code
          Case "CompanyProduction"
              'Action Code
          Case "CompanyAccounting"
              'Action Code
    End Select
Next
 
End Function

Your database must be implemented with Microsoft Access Security.


The Environ("username") will fetch you the Windows Login ID not MS-Access UserName.

The story of my life is that I'm never completely clear the first go around. Ask my wife, she has patience in getting things out of me when we're talking and I start abbreviating my thoughts.

I want to make sure the response given covers what i'm looking for. My database will be used across multiple facilities on a domain. I'm looking to gather the domain groups that a user is a member of. I do not want to use Access groups. What I'm developing will have people who are hundreds of miles apart accessing the same data on the domain. But some users may be allowed to edit data changes, others to approve data changes, etc. Politically (in work terms) the easiest way to do this is to have groups from the domain allowed certain kinds of access to certain features when allowing access to the Access database.

Thanks,
Ed

Access 2007/2010
 
Maybe this might be close. Using this api should get you the username and the domain name that they are tied to.

Code:
Private Enum EXTENDED_NAME_FORMAT
  NameUnknown = 0
  NameFullyQualifiedDN = 1
  NameSamCompatible = 2
  NameDisplay = 3
  NameUniqueId = 6
  NameCanonical = 7
  NameUserPrincipal = 8
  NameCanonicalEx = 9
  NameServicePrincipal = 10
End Enum

Private Declare Function GetUserNameExA Lib "secur32.dll" (ByVal NameFormat As EXTENDED_NAME_FORMAT, ByVal lpNameBuffer As String, ByRef nSize As Long) As Long

Public Function GetUserNameExt() As String
  Dim sBuffer As String, Ret As Long
  sBuffer = String(256, 0)
  Ret = Len(sBuffer)
  If GetUserNameExA(NameSamCompatible, sBuffer, Ret) <> 0 Then
    GetUserNameExt = Left$(sBuffer, Ret)
  Else
    GetUserNameExt = "ERROR"
  End If
End Function

Hope it helps,

TheChazm
 

Users who are viewing this thread

Back
Top Bottom