Jan 6, 2005 #1 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
Does any one know of a way to grab the username list from active directory and put it into a access table Thanks
Jan 6, 2005 #2 bradmaunsell Programmer May 8, 2001 156 US 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 Upvote 0 Downvote
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