Determine Windows Userid for Current Db Users

M

microb0x

I have a function in place to determine the current user roster for an
access db. I will paste that sub below. The results of this function
provide me with the Computer_Name, Login_Name(access's not windows),
Connected, and Suspect_State.

My question is, is there a way for me to gather all the windows logins
for every user currently in the db? The computer name is nice, but not
much use to me as I dont have a quick reliable way to attach a person
to a computer name. Additionaly some of my access applications are
accessed via a citrix environment so in those cases the computer name
is just a citrix server, and I have no way of attaching that to a user.

Basically I need the windows ID for all users that are in my database
as a given time.

Here is my current sub for determining the computer name(courtesy of
another user in this group):


Sub ShowUserRosterMultipleUsers()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim i, j As Long

'Set cn = CurrentDb.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & vDbPath

' The user roster is exposed as a provider-specific schema rowset
' in the Jet 4.0 OLE DB provider. You have to use a GUID to
' reference the schema, as provider-specific schemas are not
' listed in ADO's type library for schema rowsets

Set rs = cn.OpenSchema(adSchemaProviderSpecific, _
, "{947bb102-5d43-11d1-bdbf-00c04fb92675}")

'Output the list of all users in the current database.

DoCmd.OpenForm "frmDbUsers_Data"
With Form_frmDBUsers_Data.lstUsers
.AddItem (rs.Fields(0).Name & ";" & rs.Fields(1).Name & _
";" & rs.Fields(2).Name & ";" & rs.Fields(3).Name)
End With

While Not rs.EOF
With Form_frmDBUsers_Data.lstUsers
.AddItem (Left(Trim(rs.Fields(0)), Len(Trim(rs.Fields(0)))
- 1) & _
";" & Left(Trim(rs.Fields(1)),
Len(Trim(rs.Fields(1))) - 1) & _
";" & Trim(rs.Fields(2)) & ";" &
Trim(rs.Fields(3)))
End With
rs.MoveNext
Wend


rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing

End Sub
 
M

Michael H

Hi.

Paste the following code (courtesy of Dev Ashish) into a new module, and use
the fOSUserName function. You may also want to have a look here:
http://www.mvps.org/access/api/api0066.htm


Option Compare Database
Option Explicit

'******************** Code Start **************************
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If (lngX > 0) Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function
'******************** Code End **************************



-Michael
 
A

aaron.kempf

you guys are a bunch of flaming pussies

if you used Access Data Projects; this is built in and you don't have
to download code to do it

ADP has all of this build in; it's a ton easier to manage
 
M

microb0x

Aaron,

Thanks again for taking the time to try and bash someone who doesnt do
things your way! You again have succeeded in not solving anything,
you've provided no detail on how to this with ADP, and you've made
yourself look like a putz yet again..

I checked your profile and the majority of your responses in these news
groups, probably like 90%, all include you whining and complaing about
how other people do things rather than trying to assist in a
professional and friendly manner.

These groups are a community of people who are nice enough to take the
time to help each other out, making all our lives a little less
stressful. All you ever do it bitch and whine about people not doing
things in a manner "you" have decided is best.

Seriously bud, get a life already.


To the other people who actually provided imput into my question,
thanks for being the person this Aaron guy is obviously not.
 
M

microb0x

Michael H and/or Smartin,

Do the solution(s) you posted just retrieve the windows login for a
single user or all users currently in the db?

I think I already have a similar function for determining the windows
login for a user who is accessing the FE.

What I'm looking for is the ability to, using a access application I
wrote, point at an external access file and retrieve all the users who
are currently connected to it. I need to point to my BE file and have
it tell me who is currently connected.

Like I said in my initial post I can gather the computer name of each
person connected but I'm unsure how to get the windows login for each
person.
 
R

Ron2006

Try this link: http://www.mvps.org/access/modules/mdl0055.htm

it has a small access app that looks at the ldb file and will tell you
all of the users that are logged into mdb that you reference. I believe
it is called AppUser.mdb


really neat and small, and the code for the form can be imported into
any app that you want or run standalone out of this app. With that you
may be able to tell what machine is actually holding open the ldb file
without having to try to guess.

This one can point to ANY MDB that you have the address to.

Ron
 
R

Ron2006

When I used it here, I modified it to include a dropdown of the apps I
was interested in.

Ron
 
M

microb0x

Smartin,

Thank you, your solution will work for me. I never thought of just
taking that 'per-user' information and dumping into and external file
to track who's connected.


Ron2006,

The link you posted was also very helpful. It is using a similar
method to what I am currently doing only it also pulls the NT UserID I
am interested in.

I will most likely end up using a combination of both solutions to suit
my needs. I appreciate both of your assistance.
 
A

aaron.kempf

sp_who or sp_who2


those are sprocs

sorry microb0x i'm so sorry that you're a flaming PUSSY for using MDB.

any use of MDB in the year 2006 is laughable. MDB is OBSOLETE and it
has been for at least 7 years. Ever since MSDE 1.0 came out; MDB is
DED

-Aaron
 
A

aaron.kempf

microb0x

and btw, i checked through your posts.. and in 90% of your posts;
you're a flaming WIMP for using MDB.

MDB is DED.
 
A

aaron.kempf

i can get it done without a single line of code

dev ashish is a CRACKHEAD for using MDB

why don't you Access WIMPS go and join some other newsgroup; ADP is the
rightful heir to the 'Access' name so this group is obviously about ADP

eat shit mdb wimps!
 
M

microb0x

Funny how you're the only imbecile who says things like this. I RARELY
see any mention of ADP in this group other than your ridiculous posts.
The group is intended for the entire access community not just your
little world..

It's quite obvious that you lack the knowledge to solve any problem or
question for any access file type other than .adp

Instead, how about you go find a user group dedicated to ADP and you
can spend your time glorifying it there.

You provide nothing positive or useful to this group at all.
 
A

aaron.kempf

you're an idiot

ADP friggin rocks dude you're a lame-ass newbie

grow some balls, eunuch

-Aaron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top