borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Need help in an internet program( finding the IP))Next Topic (A beatiful experence in network) New Topic New Poll Post Reply
AndreaVB Forum : Network : Username req. from windows login or active directory.
Poster Message
is269
Level: Scholar

Registered: 24-02-2004
Posts: 35

icon 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
View Profile Send Email to User Show All Posts | Quote Reply
TJ_01
Level: VB Lord


Registered: 24-08-2005
Posts: 320
icon 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




[Edited by TJ_01 on 31-08-2005 at 12:40 AM GMT]

____________________________
Im JAMES  

31-08-2005 at 12:40 AM
View Profile Send Email to User Show All Posts | Quote Reply
is269
Level: Scholar

Registered: 24-02-2004
Posts: 35
icon Re: Username req. from windows login or active directory.

Hi,

when i run the program, it shows the error as below.


compile error :

constants, fixed length strings, arrays, user defined types and declare statements not allowed as public members of object modules.

pls. advise.

Regards.

31-08-2005 at 02:24 PM
View Profile Send Email to User Show All Posts | Quote Reply
TJ_01
Level: VB Lord


Registered: 24-08-2005
Posts: 320
icon Re: Username req. from windows login or active directory.

Ok maybe you forgot to change the code like this:

Public Declare Function GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) _
As Long


____________________________
Im JAMES  

01-09-2005 at 12:52 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Network : Username req. from windows login or active directory.
Previous Topic (Need help in an internet program( finding the IP))Next Topic (A beatiful experence in network) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder