Get Network Username ID

B

Bourdugephilippe

Hi

I am currrently trying to find the dynamic library through wich I could read
the network user ID connection name under windows 2000.
I'd like to use this to configure my MS Access database and give grants to user
who will open it.
I am not really at ease with such things so please if you know tell me how to
do. I mean if there is a function procedure to create with Alias tell me how to
this down.

Thanks a lot for help
 
C

Charles Maxson

I used this code from Excel on Office XP... let me know if that works for
(or not):


Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA"
_
(ByVal lpBuffer As String, nSize As Long) As Long

Function sUserName() As String

Dim lngLen As Long
Dim strBuffer As String

Const dhcMaxUserName = 255

strBuffer = Space(dhcMaxUserName)
lngLen = dhcMaxUserName
If CBool(GetUserName(strBuffer, lngLen)) Then
sUserName = Left$(strBuffer, lngLen - 1)
Else
sUserName = ""
End If
End Function
 

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