' ------------------------------------------------------------------------- ' From the book Inside Active Directory, ISBN 0-201-61621-1 ' Copyright (C) 2002 by Addison-Wesley ' Script by Sakari Kouti (see http://www.kouti.com) ' You have a royalty-free right to use, modify, reproduce and distribute ' this script (and/or any modified version) in any way you find useful, ' provided that you agree that Addison-Wesley or Sakari Kouti has no ' warranty, obligations or liability for the script. If you modify ' the script, you must retain this copyright notice. ' ------------------------------------------------------------------------- Option Explicit 'Dim i, j Call CreateUser("Jack") 'For i = 0 To 9 ' For j = 0 To 9 ' Call CreateUser("Uu" & CStr(i) & CStr(j)) ' Next 'Next Sub CreateUser(strName) Dim objContainer, objUser Set objContainer = _ GetObject("LDAP://OU=Sales,DC=sanao,DC=com") Set objUser = objContainer.Create("user", "CN=" & strName) Call objUser.Put("sAMAccountName", strName) Call objUser.Put("userAccountControl", &H200) Call objUser.Put("userPrincipalName", strName & "@sanao.com") objUser.SetInfo objUser.SetPassword ("secret") Set objUser = Nothing End Sub