ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Userid (https://www.excelbanter.com/excel-programming/384936-userid.html)

Marvin

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..

Tom Ogilvy

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..


Marvin

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..


Tom Ogilvy

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..


Marvin

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..



All times are GMT +1. The time now is 11:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com