Delegate Control of an OU to a User

by Len Parov.

Share
|
Homepage | Submit your article | Contact | TOS
More articles on microsoft os family  

You are here: Categories » Computers and technology » Microsoft OS family

Rather than use the Delegation of Control Wizard, use this script to delegate authority over an organizational unit (OU) to a particular user.

By delegating administrative responsibilities, you can eliminate the need for multiple administrative accounts that have broad authority (such as over an entire domain). Although you likely will still use the predefined Domain Admins group for administration of the entire domain, you can limit the accounts that are members of the Domain Admins group to highly trusted administrative users.

Administrative control can be granted to a user or group by using the Delegation of Control wizard. The Delegation of Control wizard allows you to select the user or group to which you want to delegate control, the organizational units and objects you want to grant those users the right to control, and the permissions to access and modify objects.

The Code

While using the wizard to do this is straightforward, there is a quick and easy way to achieve the same effect through VBScript. Just open a text editor such as Notepad (making sure that Word Wrap is disabled), type the following script, and save it with a .vbs extension as DelegateOU.vbs:

Set ou = GetObject("LDAP://OU=Test,OU=Users,OU=Services,OU=Network,DC=MY,DC=Domain,
DC=com")
Set sec = ou.Get("ntSecurityDescriptor")
Set acl = sec.DiscretionaryAcl
Set ace = CreateObject("AccessControlEntry") 
ace.AceType = ADS_ACETYPE_ACCESS_ALLOWED_OBJECT 
ace.AccessMask = ADS_RIGHT_DS_CREATE_CHILD Or ADS_RIGHT_DS_DELETE_CHILD 
ace.ObjectType = "{BF967ABA-0DE6-11D0-A285-00AA003049E2}" 
'User's GUID (schemaIDGuid)
ace.AceFlags = ADS_ACEFLAG_INHERIT_ACE 
ace.Flags = ADS_FLAG_OBJECT_TYPE_PRESENT 
ace.Trustee = "MY\Jsmith" 'User to delegate to
acl.AddAce ace
sec.DiscretionaryAcl = acl
ou.Put "ntSecurityDescriptor", Array(sec)
ou.SetInfo 
Set ace = Nothing
Set acl = Nothing
Set sec = Nothing

When you run this script, the result is to delegate to the user the ability to create and delete users in the MY.DOMAIN.COM/NETWORK/SERVICES/USERS/TEST organizational unit.

The first line you need to customize to make this work in your own environment is this one:

Set ou = GetObject("LDAP://OU=Test,OU=Users,OU=Services,OU=Network," & _    DC=MY,DC=Domain,DC=com")

You must insert the distinguished name (DN) of the OU to which you want to delegate this right in the LDAP URL section of the command line. For example, if you want the delegated user to be able to add and delete users in the OU called UR.DOMAINHERE.COM/HR/USERS, the line would need to look like this:

Set ou = GetObject("LDAP:// OU=Users,OU=HR,DC=Ur,DC=Domainhere,DC=com")

Here is another line you need to modify for your environment:

ace.Trustee = "MY\Jsmith" User to delegate to

In the section in double quotes ("MY\Jsmith"), you must insert the username for the user to whom you want to delegate the right to add and delete users. For example, if the user that you want to be able to ADD and DELETE users is called Janedoe, the line would look like this:

ace.Trustee = "UR\Janedoe" 'Who is the beneficiary of this ace

Make sure you have the latest scripting engines on the workstation you run this script from; you can download current scripting engines from the Microsoft Scripting home page (http://msdn.microsoft.com/library/default.asp?url=/nhp/Default.asp?contentid=28001169). When working with the Active Directory Services Interface (ADSI), you must have the same applicable rights you need to use the built-in administrative tools.

Running the Hack

To run the script, simply create a shortcut to the script and double-click on the shortcut. The script itself does the rest.

Leave a comment or ask a question
Total comments: 0

Microsoft OS family Disclaimer

  • The e-articles directory is not responsible for any and all copyright infringements by writers and authors. If you suspect the information contained by this page for any copyright infringements, please contact us to investigate the issue
Internet Explorer 8 Automatically Completes Address - Internet Explorer 8 with Windows 7 helps you surf the Internet quicker. With the latest version of IE you need not open up a new window to find information such as driving directio (more...)
Setting up a shared internet connection in Windows XP - If you have one computer connected to the internet (from now on called the "server"), and another connected to that computer (from now on called the "client") via a wirel (more...)
Find and Replace Registry Keys from a Command Line - Using the Regfind utility, you can easily search the Registry for a value, regardless of the key, and replace it. Regfind (from the Windows 2000 Server Resource Kit) can be an invalua (more...)
How to Execute a Command on Each Computer in a Domain - This handy script lets you easily run any command on a specified subset of computers in your domain. Running the same command on multiple computers in your domain can be tedious indeed, (more...)
Top Five Tools in Windows 2000 - Here's one IT professional's take on five third-party tools for Windows 2000 every system administrator should have. There can be no doubt that with every release of Microsoft's opera (more...)
Designing Active Directory for Exchange Server 2007 - Active Directory (AD) is a necessary and fundamental component of any Exchange 2007 implementation. That said, organizations do not necessarily need to panic about setting up Active Directory in (more...)
Automatically Windows Log On After Booting - It's sometimes convenient to configure machines to log on automatically when booted. Here are three ways to do this. In all versions of Windows that are based on Windows NT (including W (more...)
Bit Mapped Graphics - Windows marked the transition of the primary operating mode of PC display systems. From character-based displays, Windows ushered in the age of the bit-mapped display. Bit-mapped graphics (more...)
The Evolution of Microsoft Windows ~ Windows XP 64 bit Editions - The CPU story is not over, however. The need for processors capable of handling far more than 4GB of memory has led to development of two competing 64-bit architectures. Intel developed and pro (more...)
MS DOS Alternatives - IBM and several other PC manufacturers all sold customized versions of Microsoft's MS-DOS, and that there was a competitor called DR-DOS. Gary Kildall, whom we left several pages ago sp (more...)

 
free content
    Copyright © 2006 - 2012 e-articles.info.
The texts, articles and tutorials in the directory are property of their respective owners and authors.