Easyadsi.vbs
Option Explicit Dim oRoot, oOU, strContainer, oUser, strUser strContainer = ?LDAP://ou=finance,dc=acme,dc=com? ?********************************************************************** ?* IADs::PutEx Constants ?********************************************************************** Const ADS_PROPERTY_CLEAR = 1 Const ADS_PROPERTY_UPDATE = 2 Const ADS_PROPERTY_APPEND = 3 Const ADS_PROPERTY_DELETE = 4
A
?******************************************************************** ?* Scenario 1 ADSI Interface ?********************************************************************** Set oOU = GetObject(strContainer) Set oUser = oOU.Create(?User?, ?cn=Judy Schneider?) ? IADsContainer oUser.Put ?sAMAccountName?, ?JudyS? ? IADs oUser.SetInfo ? IADs oUser.SetPassword ?qwerty? ? IADsUser oUser.AccountDisabled = FALSE ? IADs ?********************************************************************** ?* Setting Optional User Properties ?* —————————————— ?* The following user properties are divided into groups that correspond ?* to the property pages available in the Active Directory Users and ?* Computers snap-in?s User Properties dialog box. The attribute names ?* in the code on the left are the LDAP display names of the attribute. ?* The names referenced in the comments to the right are the labels that ?* appear on the property pages. The mapping between LDAP display ?* names and property page labels is stored in the attributeDisplayNames ?* property that is a member of the displaySpecifier class. ?********************************************************************** ?* General Property Page ?********************************************************************** oUser.givenName = ?Judy? ? First Name oUser.initials = ?JAS? ? Initials oUser.sn = ?Schneider? ? Last Name oUser.displayName = ?Judy Schneider? ? Display Name oUser.description = ?Comptroller? ? Description oUser.physicalDeliveryOfficeName = ?12/3456? ? Office Location oUser.telephoneNumber = ?(111) 111-1111? ? Telephone Number oUser.otherTelephone = Array(?(222) 222-2222?, _ ?(333) 333-3333?) ? Phone Number (Others) oUser.mail = ?judys@acme.com? ? Email Address oUser.wWWHomePage = ?http://acme.com/judys? ? Web Page Address oUser.url = Array(?http://anotherUrl?, _ ?http://yetanotherUrl?) ? Web Page Address (Others) ?********************************************************************** ?* Address Property Page ?********************************************************************** oUser.streetAddress = ?1 Wall Street? ? Street Address oUser.postOfficeBox = ?N/A? ? Post Office Box oUser.l = ?New York? ? City oUser.st = ?NY? ? State/Province oUser.postalCode = ?10005? ? ZIP/Postal Code oUser.co = ?United States? ? Country ?********************************************************************** ?* Account Property Page ?********************************************************************** oUser.userPrincipalName = ?judys? ? Logon Name oUser.userWorkstations = ?jasdesktop? & ?,? & _ ?jaslaptop? ? Log On To... ? Logon Workstations oUser.pwdLastSet = CLng(-1) ? Disable ?User must change ? password at next logon? oUser.AccountExpirationDate = Date + 1 ? Account expires - End of: ?********************************************************************** ?* Profile Property Page ?********************************************************************** ? User profile - Profile path oUser.profilePath = ?%LOGONSERVER%Documents and Settingsjudys? ? User profile - Logon script oUser.scriptPath = ?logon.wsf //job:finance? ? Home Drive oUser.homeDrive = ?H:? ? Home Folder oUser.homeDirectory = ?%LOGONSERVER%Documents and Settingsjudys? ?********************************************************************** ?* Telephones Property Page ?********************************************************************** oUser.homePhone = ?(444) 444-4444? ? Home Phone oUser.otherHomePhone = Array(?(555) 555-5555?, _ ?(666) 666-6666?) ? Home Phone (Others) oUser.pager = ?(777) 777-7777? ? Pager Number oUser.otherPager = Array(?(888) 888-8888?, _ ?(999) 999-9999?) ? Pager Number (Others) oUser.mobile = ?(000) 000-0000? ? Mobile Number oUser.otherMobile = Array(?(aaa) aaa-aaaa?, _ ?(bbb) bbb-bbbb?) ? Mobile Number (Others) oUser.facsimileTelephoneNumber = _ ?(ccc) ccc-cccc? ? Fax Number oUser.otherFacsimileTelephoneNumber = _ Array(?(ddd) ddd-dddd?, ?(eee) eee-eeee?) ? Fax Number (Others) oUser.ipPhone = ?1.1.1.1? ? IP Phone Number oUser.otherIpPhone = Array(?2.2.2.2?,?3.3.3.3?) ? IP Phone Number (Others) oUser.info = ?Primary contact number: Mobile? ? Notes ?********************************************************************** ?* Organization Property Page ?********************************************************************** oUser.title = ?Senior Comptroller? ? Job Title oUser.department = ?Accounting & Finance? ? Department oUser.company = ?Acme Widgets? ? Company ?********************************************************************** ?* Miscellaneous: Not Accessible Via UI by Default... ?********************************************************************** oUser.middleName = ?Anne? ? Middle Name oUser.employeeID = ?23? ? Employee ID oUser.comment = ?Vegatarian? ? Comment oUser.personalTitle = ?Accountant? ? Title oUser.division = ?Corporate? ? Division oUser.otherMailbox = Array(?judys@hotmail.com?, _ ?judys@zdnetonebox.com?) ? Email Address (Others) oUser.homePostalAddress = ?10 Carriage Circle? ? Home Address oUser.c = ?US? ? Country Abbreviation oUser.primaryTelexNumber = ?(fff) fff-ffff? ? Telex Number oUser.telexNumber = Array(?(ggg) ggg-gggg?, _ ?(hhh) hhh-hhhh?) ? Telex Number (Others) oUser.primaryInternationalISDNNumber = _ ?InternationalISDNNumber1? ? International ISDN Number oUser.SetInfo Set oOU = Nothing Set oUser = Nothing
B
?********************************************************************** ?* Scenario 2 ADSI Interface ?********************************************************************** strUser = ?LDAP://cn=Judy Schneider,ou=finance,dc=acme,dc=com? Set oUser = GetObject(strUser) oUser.Put ?homePostalAddress?, ?39 Echo Mill Drive? ? IADs oUser.Put ?homePhone?, ?(123) 456-7890? ? IADs oUser.PutEx ADS_PROPERTY_APPEND, _ ?otherHomePhone?, _ Array(?(098) 765-4321?) ? IADs oUser.SetInfo ? IADs Set oUser = Nothing
C
?********************************************************************** ?* ADSI Interface ?********************************************************************** strContainer = ?LDAP://ou=executive,dc=acme,dc=com? strUser = ?LDAP://cn=Judy Schneider,ou=finance,dc=acme,dc=com? Set oOU = GetObject(strContainer) oOU.MoveHere strUser, ?cn=Judy Schneider? ? IADsContainer Set oOU = Nothing
D
?********************************************************************** ?* ADSI Interface ?********************************************************************** strContainer = ?LDAP://ou=executive,dc=acme,dc=com? strUser = ?LDAP://cn=Judy Schneider,ou=executive,dc=acme,dc=com? Set oOU = GetObject(strContainer) oOU.Delete ?User?, ?cn=Judy Schneider? ? IADsContainer Set oOU = Nothing Конец Листинга 2