Username req. from windows login or active directory.
Hi,
I am writing a helpdesk program where all the company users are given a form for submitting their IT related queries.
I have also placed a text box in the form where i need the user name of the person who is submitting the query should appear. So that the Helpdesk engineers can easily trace the user.
User name shud appear (automatically) either from Windows Login or from the active directory list.
Pls note that Username shud not be entered by the user.
Pls help.
Regards.
30-08-2005 at 02:17 PM
|
TJ_01 Level: VB Lord Registered: 24-08-2005 Posts: 320
Re: Username req. from windows login or active directory.
This code actually finds or get the username.
Declare Function GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) _
As Long
Private Sub Form_Load()
Dim s As String
Dim cnt As Long
Dim dl As Long
Dim CurUser As String
cnt = 199
s = String$(200, 0)
dl = GetUserName(s, cnt)
If dl <> 0 Then CurUser = Left$(s, cnt) Else CurUser = ""
Label1.Caption = CurUser
End Sub