
? ... Getting Novell Username from VB3
Quote:
>Anyone know how to get a users Novell username
>when a logged in user executes a VB3 program??
yes, you can use the next call and procedure:
'put this in youre module section on one (1) line
Declare Function wu_WNetGetUser% Lib "USER.EXE" Alias "WNetGetUser" (ByVal
szUser$, lpnBufferSize%)
'put this on the StartForm
Sub check_user ()
Dim loginname
On Error GoTo fout_user
'username opvragen
loginname = NetworkUserID()
If loginname = "" Then
MsgBox "You must logon to a Novell network..."
Unload StartForm
End If
'programma starten
Exit Sub
fout_user:
msgbox cstr(err)
Unload StartForm
End Sub
'same for this function
Function NetworkUserID () As String
Dim szUser As String * 255
Dim lpnBufferSize%
Dim status%
lpnBufferSize = 255
status = wu_WNetGetUser(szUser, lpnBufferSize)
If status = 3 Then
NetworkUserID = "Error"
Unload StartForm
Else
NetworkUserID = Left$(szUser, InStr(szUser, Chr(0)) - 1)
End If
End Function
So when you want to know the username you use the command 'check_user'. If you
make the variable LoginName (in the proc check_user) global you can use the
variable in all the other procedures.
good luck
gr. walther
n.b. it works with w3.x but also with w95.