Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

retreiveing Workgroup user id

Status
Not open for further replies.

Quotidius

Technical User
Jan 27, 2002
29
US
I can find several instances of how to retrieve the a user's network id but I am interested in retrieving both the workgroupid and user id within access.

I want to use a query that uses this capture workgroup id as a parameter so that users will see only records that belong to them.

For a reference on further background to my issue please go to thread 181-27567.

Thanks!
 
Quotidius,
Have you tried using Active Directory Service (ADS)?

Here are a couple of theads that demonstrate what you can do with ADS.
[tab]thread707-1273398 List IDs in security groups?
[tab]thread181-1242630 How to get ‘Manager’ from Outlook...
[tab]thread705-1230097 Windows User Name and Access

For development purposes you may want to add a reference to the Active DS Type Library (activeds.tlb) so you can see the properties and methods available in the object browser.

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
As a starting point you may consider the Application.CurrentUser method.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks both of you. CautionMP, the threads you provided were very helpful. PHV, your currentuser method was somewhat problematic (owing no doubt to my own coding ineptness) but I latched onto the Environ("USERNAME") which works perfectly and also is used for my underlying query so that only appropriate user rows are retrieved. Thanks again! -Q
 
Sorry, I thought you wanted the access's user name.
 
OH Great!
I did want access' user name. You mean Environ User isn't the same? I have to recheck my work. Thanks for the heads up PHV.
 
Currentuser() is the access username (admin by default)
Environ("USERNAME") is the Windows username which can be different from the network login username on Win9x machines if memory serves (it's the user associated with the stupid password list file .PWL). This is becoming a moot point because most network admin's in their right mind have kicked out all the Win9x machines by now. If you are woried try the networkuser function below...

Declare Function WNetGetUser& Lib "Mpr" Alias "WNetGetUserA" (lpName As Any, ByVal lpUserName$, lpnLength&)

Function NetworkUser() As String
'Hacked up code from ACC: How to Retrieve Workgroup Information Under Win32
'PSS ID Number: Q148835
'needs declaration: Declare Function WNetGetUser& Lib "Mpr" Alias "WNetGetUserA" (lpName As Any, ByVal lpUserName$, lpnLength&)
Dim cbusername As Long, UserName As String
Dim ret As Long
UserName = ""

' Windows 95 or NT - call WNetGetUser to get the name of the user.
UserName = Space(256)
cbusername = Len(UserName)
ret = WNetGetUser(ByVal 0&, UserName, cbusername)
If ret = 0 Then
' Success - strip off the null.
UserName = Left(UserName, InStr(UserName, Chr(0)) - 1)
Else
UserName = ""
End If
NetworkUser = UserName
End Function


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top