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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA and Active Directory

Status
Not open for further replies.

mphayesuk

IS-IT--Management
Apr 22, 2003
46
GB
Does any one know of a way to grab the username list from active directory and put it into a access table

Thanks
 
I'm not sure about "active directory", but here is a routine I use frequently.

Brad


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

Function GetNetworkUserName() As String
' Returns the network login name

Dim lngLen As Long, lngX As Long
Dim strUserName As String

strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
GetNetworkUserName = Left$(strUserName, lngLen - 1)
Else
GetNetworkUserName = ""
End If

'MsgBox "User name is: " & GetNetworkUserName
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top