Novell Home

Policy for Creating Containers

Novell Cool Solutions: Tip

Digg This - Slashdot This

Posted: 21 Oct 2005
 

Problem

A reader asked the following question about creating containers (dymanic OU's) in Identity Manager:

I'm working on a JDBC Driver 2.0. I want to create dynamic OUs in eDirectory based on dynamic data in a database table. Here is small snapshot of my code:
do-add-dest-object(class-name="Organizational Unit",direct="true",arg-dn
("myorg\"+token-local-variable("myou1"))

It's working OK, but i wanted to add logic such that if a given OU already exists, then do not create it; otherwise, create the OU. How would I do this?

And here's the reply from Forum expert "Father Ramon" - The Patron(izing) Saint of DirXML ...

Solution

Try the following code:

<policy>
	<rule>
		<description>Check if destination container already exists</description>
		<conditions>
			<and>
				<if-operation op="equal">add</if-operation>
			</and>
		</conditions>
		<actions>
			<do-set-local-variable name="target-container">
				<arg-string>
					<token-text>myorg\</token-text>
					<token-local-variable name="myou1"/>
				</arg-string>
			</do-set-local-variable>
			<do-set-local-variable name="does-target-exist">
				<arg-string>
					<token-dest-attr class-name="OrganizationalUnit" name="objectclass">
						<arg-dn>
							<token-local-variable name="target-container"/>
						</arg-dn>
					</token-dest-attr>
				</arg-string>
			</do-set-local-variable>
		</actions>
	</rule>
	<rule>
		<description>Create the target container if necessary</description>
		<conditions>
			<and>
				<if-local-variable name="does-target-exist" op="available"/>
				<if-local-variable name="does-target-exist" op="equal"/>
			</and>
		</conditions>
		<actions>
			<do-add-dest-object class-name="organizationalUnit" direct="true">
				<arg-dn>
					<token-local-variable name="target-container"/>
				</arg-dn>
			</do-add-dest-object>
			<do-add-dest-attr-value direct="true" name="ou">
				<arg-dn>
					<token-local-variable name="target-container"/>
				</arg-dn>
				<arg-value type="string">
					<token-parse-dn dest-dn-format="dot" length="1" src-dn-format="dest-dn" start="-1">
						<token-local-variable name="target-container"/>
					</token-parse-dn>
				</arg-value>
			</do-add-dest-attr-value>
		</actions>
	</rule>
</policy>


Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

© 2014 Novell