Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieve Windows NT login information

Status
Not open for further replies.

jcpelejo

Programmer
Joined
Jul 29, 2001
Messages
70
Location
US
Hello. I was wondering if it it possible to retrieve logon information for all individuals in a certain NT domain. What I would like to do is retrieve the User ID, Date of login and Time of login information. Then I would like to place the information into an Access database. Please advise.
Life is too short to waste...
Julius Pelejo
jcpelejo@hotmail.com
 
Include Active DS Type Library.

This gets the Login and Full Name off the server.
There are lots of different things you can find out.

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


Public Function fncGetUserFullName() As String

On Error GoTo errorHandler

Dim oUser As ActiveDs.IADsUser

Set oUser = GetObject("WinNT://YOURDOMAINHERE/" & fncGetUserLogin)

fncGetUserFullName = oUser.FullName()

Exit Function

errorHandler:

fncGetUserFullName = "Anonymous"

End Function

Public Function fncGetUserLogin() As String

On Error GoTo errorHandler

Dim s As String
Dim cnt As Long
Dim dl As Long

cnt = 199
s = String$(200, 0)
dl = GetUserName(s, cnt)
If dl <> 0 Then fncGetUserLogin = Left$(s, cnt - 1) Else fncGetUserLogin = &quot;&quot;

Exit Function

errorHandler:

fncGetUserLogin = &quot;Anonymous&quot;

End Function
 
Dim oUser As ActiveDs.IADsUser
msgbox oUser.LastLogin '<-- Date and Time of last login...
:-)
 
Any easier way is...
Environ(&quot;username&quot;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top