So the user's don't have individual logins to the SQL server...?
Well, I don't know if the function works in VB or on Win 2000 but it should, so create a new project and try:
msgbox Environ$("UserName"
and see what you get. Other than that I can't be of any help, since I'm not aware of any way to get the username off the lan besides the Environ$() function or the API call which is the EXACT same thing... Kyle :
That works.. thanks..I give the users access to a global DB where I have a table that tells me what applications the users can access and access level. I use NT auth. for that. But I don't give them rights application databases. I create a proxy acount for each app and I grant rights to the proxy. Thanks for your help.
Tbanks KyleS. That deserves a star. I had not known about the Eviron$ function. I checked on msdn.microsoft.com to be sure that it was present in VB.Net and it is. I'm not writing any more code, including Control Arrays, that does not translate to "native" VB.Net i.e. no VB6 compatibility classes.
How about using the GetUserName function in the WinAPI:
Public Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
nSize = Len(sUser)
nSuccess = GetUserName(sUser, nSize)
If nSuccess <> 0 Then
sUserName = Left(sUser, nSize - 1)
Else
'cant get it
End If
or use the WSH if it's installed:
Err.Clear
On Error Resume Next
Set oNetwork = CreateObject("WScript.Network"
If Err.Num = 0 Then
sUserName = oNetwork.UserName
Else
'cant get it
End If Jon Hawkins
Just because I want to share.....
Some of what you're talking about is beyond me - just - but I only discovered 'environ()/environ$()' 2 weeks ago after much heartache trying to understand (unsuccessfully) api calls.
For anyone just looking for information there is a list of parameters that can be applied to environ($) if you type set at a dos prompt you get this list and the current settings. This will save time if you are trying to discover whether or not the environ($) function will work for you.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.