Skip to Main Content
Active Directory, 3rd Edition
book

Active Directory, 3rd Edition

by Joe Richards, Robbie Allen, Alistair G. Lowe-Norris
January 2006
Beginner content levelBeginner
832 pages
27h 52m
English
O'Reilly Media, Inc.
Content preview from Active Directory, 3rd Edition

Chapter 23. Users and Groups

In this chapter, we will show you how to automate the creation and manipulation of user and group accounts . Although tools to create user and group accounts already exist (e.g., the Windows 2000 Resource Kit's Addusers utility), ADSI's versatility lets you quickly write a script that creates 1,000 fully featured user or group accounts based on whatever business logic you require. You can also create command-line utilities or web-based interfaces using the techniques shown in this chapter to perform such functions as unlocking locked-out user accounts or adding users to groups.

Creating a Simple User Account

You can quickly create a user account with minimal attributes with ADSI. The following code shows how to create a user in an NT domain, a local computer, and an Active Directory domain:

 Option Explicit Dim objDomain, objUser 'Creating a user in a Windows NT domain Set objDomain = GetObject("WinNT://MYDOMAIN") Set objUser = objDomain.Create("user","vlaunders") objUser.SetInfo 'Creating a local user on a computer or member server 'Valid for Windows NT/2000/2003 Set objComputer = GetObject("WinNT://MYCOMPUTER,Computer") Set objUser = objComputer.Create("user","vlaunders") objUser.SetInfo 'Creating a user in Active Directory Set objDomain = GetObject("LDAP://cn=Users,dc=mycorp,dc=com") Set objUser = objDomain.Create("user","cn=vlaunders") objUser.Put "sAMAccountName", "vlaunders" objUser.Put "userPrincipalName", "vlaunders@mycorp.com" objUser.SetInfo ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Active Directory, 4th Edition

Active Directory, 4th Edition

Brian Desmond, Joe Richards, Robbie Allen, Alistair G. Lowe-Norris
Active Directory, Second Edition

Active Directory, Second Edition

Robbie Allen, Alistair G. Lowe-Norris

Publisher Resources

ISBN: 0596101732Supplemental ContentErrata Page