Get Local Machine Name

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello. Is there a way to retrieve properties, such as the local machine
name, user logged on and group membership using VBA?
 
Computer name:
http://www.mvps.org/access/api/api0009.htm

Network user name:
http://www.mvps.org/access/api/api0008.htm

If you are using Access Security (system.mdw file), you can get the Access
user name as:
CurrentUser()
The user could be a member of more than one group, but if you want to know
whether they are a member of a particular group:

Function IsUserInGroup(strUser As String, strGroup As String) As Boolean
Dim varDummy As Variant
On Error Resume Next
varDummy = DBEngine(0).Users(strUser).Groups(strGroup).Name
IsUserInGroup = (Err.Number = 0)
End Function
 
Awesome. Thanks!

Allen Browne said:
Computer name:
http://www.mvps.org/access/api/api0009.htm

Network user name:
http://www.mvps.org/access/api/api0008.htm

If you are using Access Security (system.mdw file), you can get the Access
user name as:
CurrentUser()
The user could be a member of more than one group, but if you want to know
whether they are a member of a particular group:

Function IsUserInGroup(strUser As String, strGroup As String) As Boolean
Dim varDummy As Variant
On Error Resume Next
varDummy = DBEngine(0).Users(strUser).Groups(strGroup).Name
IsUserInGroup = (Err.Number = 0)
End Function
 
One question actually ... the script below to determine group membership is
exactly what I want. The problem is that it always returns a false value for
me.

Is there something missing or that I am doing wrong?
 
If you have not set up Access security, CurrentUser() will return Admin, and
you will be a member of the Admins group.

You should therefore get True from:
? IsUserInGroup("Admin", "Admins")
 
Gotcha. What I was actually looking for was a way to determine group
memebership on a machine/AD level.
 
Back
Top