Novell Home

Building a Placement Policy

Novell Cool Solutions: Tip
By Alfredo Luiz Santos

Digg This - Slashdot This

Posted: 21 Oct 2005
 

Problem

At times a user object needs to be placed in a target directory based on user attributes data like Location, Department, etc. This tip shows how to create a single Placement Policy to do this, that's more flexible and easy to manage.

Solution

You will need to prepare one object to be an XML map of the target containers. Using Policy Builder, follow these steps:

  1. Read the configuration xml and the user attribute data.
  2. Search the XML using XPATH to identify the correct container.
  3. Use a default container (Global configuration value) if no match is found on the user data and send an e-mail alert to the helpdesk.

Example

Here is a code sample that carries out the above steps:

<?xml version="1.0" encoding="UTF-8"?><policy xmlns:ncs="http://www.novell.com/nxsl/java/com.novell.ncs.dirxml.utilities.Utils" xmlns:query="http://www.novell.com/nxsl/java/com.novell.nds.dirxml.driver.XdsQueryProcessor">
	<rule>
		<description>SubscriberPlacementRuleUsingMap</description>
		<conditions>
			<or>
				<if-class-name mode="nocase" op="equal">User</if-class-name>
				<if-class-name mode="nocase" op="equal">Organizational Unit</if-class-name>
			</or>
		</conditions>
		<actions>
			<do-set-local-variable name="XPTOConfigQueryResult">
				<arg-node-set>
					<token-xpath expression='query:search($srcQueryProcessor,"subtree","","basf\br","XPTOConfig","XPTOConfigID","XPTOBRConfig","XPTONDSXML")'/>
				</arg-node-set>
			</do-set-local-variable>
			<do-set-local-variable name="XPTONDSXMLTEXT">
				<arg-string>
					<token-xpath expression="$XPTOConfigQueryResult//value"/>
				</arg-string>
			</do-set-local-variable>
			<do-set-local-variable name="XPTONDSXML">
				<arg-node-set>
					<token-xpath expression="ncs:getDocumentFromString($XPTONDSXMLTEXT)"/>
				</arg-node-set>
			</do-set-local-variable>
			<do-set-local-variable name="XPTOUserType">
				<arg-string>
					<token-attr name="XPTOUserType"/>
				</arg-string>
			</do-set-local-variable>
			<do-set-local-variable name="Department">
				<arg-string>
					<token-attr name="OU"/>
				</arg-string>
			</do-set-local-variable>
			<do-set-local-variable name="Location">
				<arg-string>
					<token-attr name="L"/>
				</arg-string>
			</do-set-local-variable>
			<do-set-local-variable name="ContainerResult">
				<arg-string>
					<token-xpath expression="$XPTONDSXML//container[@location=$Location][@type=$XPTOUserType][@department=$Department]/text()"/>
				</arg-string>
			</do-set-local-variable>
		</actions>
	</rule>
	<rule>
		<description>Verifica Nao Identificados</description>
		<conditions>
			<and>
				<if-local-variable mode="nocase" name="ContainerResult" op="equal"/>
			</and>
		</conditions>
		<actions>
			<do-set-local-variable name="ContainerResult">
						<token-text xml:space="preserve">, com isso o usuário foi criado no Container Nao_Identificados.</token-text>
				</arg-string>
			</do-send-email>
		</actions>
	</rule>
	<rule>
		<description>Implementa Container</description>
		<conditions>
			<or>
				<if-class-name mode="nocase" op="equal">User</if-class-name>
				<if-class-name mode="nocase" op="equal">Organizational Unit</if-class-name>
			</or>
		</conditions>
		<actions>
			<do-set-op-dest-dn>
				<arg-dn>
					<token-text xml:space="preserve">CN=</token-text>
					<token-attr name="CN"/>
					<token-text xml:space="preserve">,</token-text>
					<token-local-variable name="ContainerResult"/>
				</arg-dn>
			</do-set-op-dest-dn>
		</actions>
	</rule>
</policy>


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

© 2014 Novell