Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Win API / October 2003



Tip: Looking for answers? Try searching our database.

How do I obtain the NT login Id?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Acie Martin - 28 Oct 2003 05:16 GMT
In an application, I need to obtain the NT login id that
is currently logged on.

Any help would be greatly appreciated.

Thanks,
Acie
Roy Soltoff - 30 Oct 2003 19:43 GMT
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA"
_
 (ByVal lpBuffer As String, nSize As Long) As Long

 Dim lngCount As Integer
 Dim lngRetCod As Long
 Dim strUsername As String
 Dim strLoginName As String * 64
 Dim strNull As String

 '
 ' Get the login name to use in fetching preferences
 '
 lngRetCod = GetUserName(strLoginName, 64)        ' Get the windows login
name
 strNull = Chr$(0)
 lngCount = InStr(strLoginName, strNull)
 If (lngCount = 1) Then
   ' No user name available
   strUsername = "User"
 ElseIf (lngCount > 0) Then
   strUsername = Left$(strLoginName, lngCount - 1)
 Else
   strUsername = strLoginName
 End If

> In an application, I need to obtain the NT login id that
> is currently logged on.
[quoted text clipped - 3 lines]
> Thanks,
> Acie
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.