#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Userid

Is there a way I can determine the windows USERID of the current user. I
would like to make some functionality available to some, but not all users?

Thanks..
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Userid

UName = Environ("Username")

demo'd from the immediate window:

? environ("username")
ogilvytw

--
Regards,
Tom Ogilvy


"Marvin" wrote:

Is there a way I can determine the windows USERID of the current user. I
would like to make some functionality available to some, but not all users?

Thanks..

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Userid

Thanks. This is getting closer, but it is not the login ID.

In my case, my Windows login ID is "wapnits", byt your technique returns
"Marvin". Further, I have the ability to change the environment, but cannot
change the userid. Thus, userid is more secure in preventing my user from
doing things he shouldn't do.

"Tom Ogilvy" wrote:

UName = Environ("Username")

demo'd from the immediate window:

? environ("username")
ogilvytw

--
Regards,
Tom Ogilvy


"Marvin" wrote:

Is there a way I can determine the windows USERID of the current user. I
would like to make some functionality available to some, but not all users?

Thanks..

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Userid

this give me the same, but maybe you will get different:

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

Sub GetUserNameTest()
MsgBox fOSUserName
End Sub

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 = ""
End If
End Function

--
Regards,
Tom Ogilvy


"Marvin" wrote:

Thanks. This is getting closer, but it is not the login ID.

In my case, my Windows login ID is "wapnits", byt your technique returns
"Marvin". Further, I have the ability to change the environment, but cannot
change the userid. Thus, userid is more secure in preventing my user from
doing things he shouldn't do.

"Tom Ogilvy" wrote:

UName = Environ("Username")

demo'd from the immediate window:

? environ("username")
ogilvytw

--
Regards,
Tom Ogilvy


"Marvin" wrote:

Is there a way I can determine the windows USERID of the current user. I
would like to make some functionality available to some, but not all users?

Thanks..

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Userid

Perfect. Thanks. What was the source of your information, and how can I
acquire it?

"Tom Ogilvy" wrote:

this give me the same, but maybe you will get different:

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

Sub GetUserNameTest()
MsgBox fOSUserName
End Sub

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 = ""
End If
End Function

--
Regards,
Tom Ogilvy


"Marvin" wrote:

Thanks. This is getting closer, but it is not the login ID.

In my case, my Windows login ID is "wapnits", byt your technique returns
"Marvin". Further, I have the ability to change the environment, but cannot
change the userid. Thus, userid is more secure in preventing my user from
doing things he shouldn't do.

"Tom Ogilvy" wrote:

UName = Environ("Username")

demo'd from the immediate window:

? environ("username")
ogilvytw

--
Regards,
Tom Ogilvy


"Marvin" wrote:

Is there a way I can determine the windows USERID of the current user. I
would like to make some functionality available to some, but not all users?

Thanks..

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I get network userid in a cell in excel? Kalpana_Kar Excel Programming 2 March 29th 06 11:16 PM
Log UserID JJ Excel Programming 3 March 9th 05 01:30 PM
DSN UserId and Password Prompt bslater[_13_] Excel Programming 0 September 22nd 04 09:02 PM
DSN UserId and Password Prompt bslater[_12_] Excel Programming 1 September 22nd 04 08:30 PM
FileSystemObject CopyFile with UserID/Password Tod[_3_] Excel Programming 0 January 7th 04 06:03 PM


All times are GMT +1. The time now is 01:49 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"