Code Script .co.uk

Home | Scripts | Tutorials | Disclaimer | Sitemap | Contact

   Enumerate Ad Users
 

Vbscript / Active Directory / Enumerate Ad Users

This script retrieves all user objects in an OU and assigns variables to some basic properties. Insert any operation you require instead of the Wscript.Echo line.


strOU = "Users"
strDomain = "dc=domain,dc=local"


Set objOU = GetObject("LDAP://ou=" & strOU & "," & strDomain)

objOU.Filter = Array("user")

For Each objUser in objOU

userName = objUser.SAMAccountName
userDisplay = objUser.cn
userHome = objUser.HomeDirectory
userProfile = objUser.Profile

Wscript.Echo userName & " - " & userHome

Next

Set objOU = Nothing
Set objUser = Nothing


 





Please note that a disclaimer applies to any code on this page.
 
   Actions
  Go Back
  Bookmark
  Print Page


   Menu
 
- Links
- Reference
- Script Editors
- Tutorials
- Vbscript
     - Active Directory
          - Ad User Information Query
          - Add Machine To Domain
          - Add User To Group
          - Create Group
          - Create Ou Structure
          - Enumerate Ad Users
          - Enumerate Group Members
          - Move Users And Groups Between Ous
          - Raise Domain Functional Level
     - Exchange
     - Files And Folders
     - General
     - Ms Office
     - Operating System
     - Processes And Services
     - Text Processing
     - User Interaction
     - Web Servers