4.14. Creating a Dynamic Object
Tip
This recipe requires the Windows Server 2003 forest functional level.
Problem
You want to create an object that is automatically deleted after a period of time unless it is refreshed.
Solution
Using a graphical user interface
At the time of publication of this book, neither ADSI Edit nor LDP supported creating dynamic objects.
Using a command-line interface
Create an LDIF file called create_dynamic_object.ldf with the following contents:
dn: cn=jsmith,cn=users,dc=rallencorp,dc=com changetype: add objectClass: user objectClass: dynamicObject entryTTL: 1800 sAMAccountName: jsmith
then run the following command:
> ldifde -v -i -f create_dynamic_object.ldf
Using VBScript
' This code creates a dynamic user object with a TTL of 30 minutes (1800 secs)
set objUsersCont = GetObject("LDAP://cn=users,dc=rallencorp,dc=com")
set objUser = objUsersCont.Create("user", "CN=jsmith")
objUser.Put "objectClass", "dynamicObject"
objUser.Put "entryTTL", 1800
objUser.Put "sAMAccountName", "jsmith" ' mandatory attribute
objUser.SetInfoDiscussion
The ability to create dynamic objects is a new feature in Windows
Server 2003. To create a dynamic object, you simply need to specify
the objectClass to have a value of
dynamicObject in addition to its structural
objectClass (e.g., user) value
when instantiating the object. The entryTTL
attribute can also be set to the number of seconds before the object
is automatically deleted. If entryTTL is not set,
the object will use the dynamicObjectDefaultTTL ...