You are here:

ActiveXperts.com > ActiveXperts Network Monitor > WindowsManagement > Scripts > Other Directory Services > ADAM > Creating, Deleting and Modifying Objects

ActiveXperts Network Monitor
Monitor servers, workstations, devices and applications in your network

Quicklinks


Creating, Deleting and Modifying ADAM Objects

Add All Users in an ADAM OU to a Group
Add a User to the ADAM Administrators Group
Add a User to an ADAM Group
Create an ADAM Container
Create an ADAM Contact Account
Create an ADAM Group
Create an ADAM inetOrgPerson Account
Create an ADAM OU
Create an ADAM User Account
Create a Child ADAM OU
Delete an ADAM Container
Delete an ADAM Contact Account
Delete an ADAM Group
Delete an ADAM inetOrgPerson Account
Delete an ADAM OU
Delete an ADAM User Account
List All the Contacts in an ADAM OU
Modify an ADAM Contact Account Property
Modify an ADAM Container Account Property
Modify an ADAM Group Account Property
Modify an ADAM inetOrgPerson Account Property
Modify an ADAM OU Property
Modify an ADAM User Account Expiration Date
Modify an ADAM User Account Property
Rename an ADAM User Account
Remove a User from an ADAM Group


You can use any of the VBScript programs below in ActiveXperts Network Monitor. Click here for an explanation about how to include scripts in ActiveXperts Network Monitor.



Add All Users in an ADAM OU to a Group


Adds all the users in the Accounting OU to an ADAM group named Accountants.
On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
Set objGroup = GetObject _
    ("LDAP://localhost:389/cn=Accountants,ou=Accounting,dc=fabrikam,dc=com")
objOU.Filter = Array("user")

For Each objUser in objOU
    objGroup.Add objUser.AdsPath
Next
	

Add a User to the ADAM Administrators Group


Adds the user Kenmyer to the ADAM Administrators group.
On Error Resume Next

Set objGroup = GetObject _
    ("LDAP://localhost:389/CN=Administrators,CN=Roles,dc=fabrikam,dc=com")
Set objUser = GetObject _
    ("LDAP://localhost:389/cn=kenmyer,ou=Accounting,dc=fabrikam,dc=com")
objGroup.Add objUser.AdsPath
	

Add a User to an ADAM Group


Adds the user Kenmyer to an ADAM group named Accountants.
On Error Resume Next

Set objGroup = GetObject _
    ("LDAP://localhost:389/cn=Accountants,ou=Accounting,dc=fabrikam,dc=com")

Set objUser = GetObject _
    ("LDAP://localhost:389/cn=kenmyer,ou=Accounting,dc=fabrikam,dc=com")
objGroup.Add objUser.AdsPath
	

Create an ADAM Container


Creates an ADAM container named Users.
On Error Resume Next

Set objDomain = GetObject("LDAP://localhost:389/dc=fabrikam,dc=com")
Set objOU = objDomain.Create("container", "cn=Users")
objOU.SetInfo
	

Create an ADAM Contact Account


Creates an ADAM contact named Jonathanhaas.
On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
Set objUser = objOU.Create("contact", "cn=jonathanhaas")
objUser.Put "displayName", "Jonathan Haas"  
objUser.SetInfo
	

Create an ADAM Group


Creates a new ADAM group named Accountants.
On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
Set objGroup = objOU.Create("group", "cn=Accountants")
objGroup.SetInfo
	

Create an ADAM inetOrgPerson Account


Creates a new ADAM inetOrgPerson account named Syedabbas.
On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
Set objUser = objOU.Create("inetOrgPerson", "cn=syedabbas")
objUser.Put "displayName", "Syed Abbas"  
objUser.SetInfo
	

Create an ADAM OU


Creates a new ADAM OU named Management.
On Error Resume Next

Set objDomain = GetObject("LDAP://localhost:389/dc=fabrikam,dc=com")
Set objOU = objDomain.Create("organizationalUnit", "ou=Management")
objOU.SetInfo
	

Create an ADAM User Account


Creates a new ADAM user account named Gailerickson.
On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
Set objUser = objOU.Create("user", "cn=gailerickson")
objUser.Put "displayName", "Gail Erickson"  
objUser.Put "userPrincipalName", "gailerickson@fabrikam.com"
objUser.SetInfo
	

Create a Child ADAM OU


Creates a new ADAM OU within the Management2 OU.
On Error Resume Next

Set objParentOU = GetObject _
    ("LDAP://localhost:389/ou=Management2,ou=Management,dc=fabrikam,dc=com")

Set objChildOU = objParentOU.Create("organizationalUnit", "ou=Level3")
objChildOU.SetInfo
	

Delete an ADAM Container


Deletes an ADAM container named Users.
On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
objOU.Delete "container", "cn=Users"
	

Delete an ADAM Contact Account


Deletes an ADAM contact account named Carolphilips.
On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
objOU.Delete "contact", "cn=carolphilips"
	

Delete an ADAM Group


Deletes an ADAM group named Accountants.
On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
objOU.Delete "group", "cn=Accountants"
	

Delete an ADAM inetOrgPerson Account


Deletes an ADAM inetOrgPerson account named Carolphilips.
On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
objOU.Delete "inetOrgPerson", "cn=carolphilips"
	

Delete an ADAM OU


Deletes an ADAM OU named Accounting.
On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/dc=fabrikam,dc=com")
objOU.Delete "organizationalUnit", "ou=Accounting"
	

Delete an ADAM User Account


Deletes an ADAM user account named Carolphilips.
On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
objOU.Delete "user", "cn=carolphilips"
	

List All the Contacts in an ADAM OU


Lists all the contacts in an ADAM OU named Accounting.
On Error ResumeNext

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
objOU.Filter = Array("contact")

For Each objUser in objOU
    Wscript.Echo objUser.Name
Next
	

Modify an ADAM Contact Account Property


Modifies the description attribute for an ADAM contact named Carolphilips.
On Error Resume Next

Set objUser = GetObject _
    ("LDAP://localhost:389/cn=carolphilips,ou=Accounting,dc=fabrikam,dc=com")

objUser.Put "description", "This is a practice contact account."  
objUser.SetInfo
	

Modify an ADAM Container Account Property


Modifies the description attribute for an ADAM container named Users.
On Error Resume Next

Set objUser = GetObject("LDAP://localhost:389/cn=users,dc=fabrikam,dc=com")

objUser.Put "description", "This is a practice container."  
objUser.SetInfo
	

Modify an ADAM Group Account Property


Modifies the description attribute for an ADAM group named Accountants.
On Error Resume Next

Set objUser = GetObject _
    ("LDAP://localhost:389/cn=Accountants,ou=Accounting,dc=fabrikam,dc=com")

objUser.Put "description", "This is a practice group account."  
objUser.SetInfo
	

Modify an ADAM inetOrgPerson Account Property


Modifies the description attribute for an ADAM inetOrgPerson account named Syedabbas.
On Error Resume Next

Set objUser = GetObject _
    ("LDAP://localhost:389/cn=syedabbas,ou=Accounting,dc=fabrikam,dc=com")

objUser.Put "description", "This is a practice inetOrgPerson account."  
objUser.SetInfo
	

Modify an ADAM OU Property


Modifies the description attribute for an ADAM OU named Accounting.
On Error Resume Next

Set objUser = GetObject _
    ("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")

objUser.Put "description", "This is a practice organizational unit."  
objUser.SetInfo
	

Modify an ADAM User Account Expiration Date


Modifies the account expiration date for an ADAM user named Kenmyer.
On Error Resume Next

Set objUser = GetObject _
    ("LDAP://localhost:389/cn=kenmyer,ou=Accounting,dc=fabrikam,dc=com")

objUser.AccountExpirationDate = "03/30/2005"
objUser.SetInfo
	

Modify an ADAM User Account Property


Modifies the description attribute for an ADAM user account named Kenmyer.
On Error Resume Next

Set objUser = GetObject _
    ("LDAP://localhost:389/cn=kenmyer,ou=Accounting,dc=fabrikam,dc=com")

objUser.Put "description", "This is a practice user account."  
objUser.SetInfo
	

Rename an ADAM User Account


Renames the ADAM user account Kimabercrombie to Dylanmiller.
On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")

objOU.MoveHere _
   "LDAP://cn=kimabercrombie, ou=Accounting,dc=fabrikam,dc=com", _
        "cn=dylanmiller"
	

Remove a User from an ADAM Group


Removes a user named TestUser from the ADAM group Accountants.
On Error Resume Next

Const ADS_PROPERTY_DELETE = 4 

Set objGroup = GetObject _
    ("LDAP://localhost:389/cn=Accountants,ou=Accounting,dc=fabrikam,dc=com")

objGroup.PutEx ADS_PROPERTY_DELETE, "member", Array("cn=TestUser,ou=Accounting,dc=fabrikam,dc=com")
objGroup.SetInfo