Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Function GetAllUsers()
' Description: Returns all Users in the entire current domain.
' Retuns: an array with the users found
Dim objRootDSE, objConnection, objCommand, objRecordSet, objUser
Dim OutPut
Set objRootDSE = GetObject("LDAP://rootDSE")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = "<LDAP://" & objRootDSE.get("defaultNamingContext") & _
">;(&(objectCategory=person)(objectClass=user));" & _ "distinguishedName,sAMAccountName;subtree"
Set objRecordSet = objCommand.Execute
ReDim OutPut(0)
While Not objRecordSet.EOF
On Error Resume next
Set objUser = GetObject("LDAP://" & objRecordSet.Fields("distinguishedName") & "")
If Err.Number = 0 then
'Do a binary comparison to see if account is disabled
If Not objUser.get("userAccountControl") And 2 Then
If OutPut(0) <> "" Then ReDim Preserve OutPut(UBound(OutPut) + 1)
' OutPut(UBound(OutPut)) = SearchGivenName (objRecordSet.Fields("sAMAccountName"))
OutPut(UBound(OutPut)) = objRecordSet.Fields("sAMAccountName")
End If
End if
On Error GoTo 0
Set objUser = Nothing
objRecordSet.MoveNext
Wend
objConnection.Close
GetAllUsers = OutPut
Set objRecordSet = Nothing
Set objCommand = Nothing
Set objConnection = Nothing
Set objRootDSE = Nothing
End Function