Friday, December 27, 2019

How to convert any application-specific JSON to XDS format for NetIQ REST driver to consume


How to convert any application-specific JSON  to XDS format for NetIQ REST driver to consume


See tip: MessageValueTextToNetIQ


<rule>
<description>Successfull poll-users command handler actions bases on trigger job;</description>
<conditions>
<and>
<if-operation mode="regex" op="equal">status</if-operation>
<if-xpath op="true">./driver-operation-data[@command="custom-IDM-JOB-GET-USERS"]</if-xpath>
<if-local-variable mode="nocase" name="StatusValue" op="equal">200</if-local-variable>
</and>
</conditions>
<actions>
<do-trace-message>
<arg-string>
<token-text xml:space="preserve">poll-users completed successfully; </token-text>
</arg-string>
</do-trace-message>
<do-set-local-variable name="StatusValue" scope="policy">
<arg-string>
<token-xpath expression="./driver-operation-data/response/value/@status"/>
</arg-string>
</do-set-local-variable>
<do-trace-message>
<arg-string>
<token-text xml:space="preserve">Status value  =></token-text>
<token-local-variable name="StatusValue"/>
</arg-string>
</do-trace-message>
<do-set-local-variable name="MessageValue" scope="policy">
<arg-string>
<token-xpath expression="./driver-operation-data/response/value/@message"/>
</arg-string>
</do-set-local-variable>
<do-trace-message>
<arg-string>
<token-text xml:space="preserve">Status value  =></token-text>
<token-local-variable name="MessageValue"/>
</arg-string>
</do-trace-message>
<do-set-local-variable name="MessageValueText" scope="policy">
<arg-string>
<token-xpath expression="./driver-operation-data/response/value/text()"/>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="MessageValueTextToNetIQ" scope="policy">
<arg-string>
<token-text xml:space="preserve">{ "totalResults": "$getCount$","results": [
</token-text>
<token-local-variable name="MessageValueText"/>
<token-text xml:space="preserve">]}</token-text>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="xmlInput" scope="policy">
<arg-string>
<token-base64-encode charset="UTF-8">
<token-replace-all regex="&amp;lt;" replace-with="&lt;">
<token-xml-serialize>
<token-text xml:space="preserve">&lt;status event-id="" level="success" type="driver-general">
      &lt;driver-operation-data api="targetURL:" class-name="users" command="query" dest-dn="" event-id="" src-dn="">
        &lt;response method="GET" url="">
          &lt;header accept="application/json" content-type="application/json"/>
   &lt;value message="OK" status="200">
   $MessageValueTextToNetIQ$
   &lt;/value>
        &lt;/response>
      &lt;/driver-operation-data>
    &lt;/status></token-text>
</token-xml-serialize>
</token-replace-all>
</token-base64-encode>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="applicationContent" scope="policy">
<arg-string>
<token-xpath expression="rs:jsonToXDS($xmlInput)"/>
</arg-string>
</do-set-local-variable>
<do-if>
<arg-conditions>
<and>
<if-local-variable mode="nocase" name="applicationContent" op="not-equal"/>
</and>
</arg-conditions>
<arg-actions>
<do-set-local-variable name="xdscontent" scope="policy">
<arg-node-set>
<token-xml-parse>
<token-local-variable name="applicationContent"/>
</token-xml-parse>
</arg-node-set>
</do-set-local-variable>
<do-set-local-variable name="users" scope="policy">
<arg-node-set>
<token-xpath expression="$xdscontent/*//*[local-name()='value']"/>
</arg-node-set>
</do-set-local-variable>
<do-trace-message>
<arg-string>
<token-text xml:space="preserve">total users available =></token-text>
<token-xpath expression="count($users)"/>
</arg-string>
</do-trace-message>
</arg-actions>
<arg-actions/>
</do-if>
<do-strip-xpath expression="./driver-operation-data"/>
</actions>undefined</rule>

Wednesday, December 25, 2019

Submit multiple SOAP calls form one modify operation generated from subscriber command



Put this policy on output.


<rule>
   <description>Update CostCenter SOAP doc</description>
   <comment name="author" xml:space="preserve">Maqsood Ali Bhatti</comment>
   <comment name="version" xml:space="preserve">5</comment>
   <comment name="lastchanged" xml:space="preserve">Sep 20, 2016</comment>
   <conditions>
     <and>
       <if-operation mode="regex" op="equal">modify</if-operation>
       <if-op-attr name="customCommand" op="changing" />
       <if-op-attr mode="regex" name="customCommand" op="equal">updateCostCenter.*</if-op-attr>
     </and>
   </conditions>
   <actions>
     <!-- add operaiton data -->
     <do-for-each>
       <arg-node-set>
         <token-op-attr name="customCommand" />
       </arg-node-set>
       <arg-actions>
         <do-set-local-variable name="local.sub.etp.Command" scope="policy">
           <arg-string>
             <token-local-variable name="current-node" />
           </arg-string>
         </do-set-local-variable>
         <do-set-local-variable name="local.sub.etp.Command" scope="policy">
           <arg-string>
             <token-local-variable name="current-node" />
           </arg-string>
         </do-set-local-variable>
         <do-set-local-variable name="local.sub.etp.Command" scope="policy">
           <arg-string>
             <token-xpath expression="substring-after($local.sub.etp.Command,'updateCostCenter:')" />
           </arg-string>
         </do-set-local-variable>
         <do-set-local-variable name="local.sub.etp.Ttext" scope="policy">
           <arg-string>
             <token-xpath expression="substring-before($local.sub.etp.Command,'#')" />
           </arg-string>
         </do-set-local-variable>
         <do-set-local-variable name="local.sub.etp.ExtCode" scope="policy">
           <arg-string>
             <token-xpath expression="substring-after($local.sub.etp.Command,'#')" />
           </arg-string>
         </do-set-local-variable>
         <do-set-local-variable name="local.otp.SOAP" scope="policy">
           <arg-node-set>
             <token-xml-parse>
               <token-text xml:space="preserve"> &lt;soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:uri="uri:FlexForce" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"> &lt;soapenv:Header/> &lt;soapenv:Body> &lt;uri:wsdlUpdateTextItems soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> &lt;apiKey xsi:type="xsd:string">$local.otp.APIKey$&lt;/apiKey> &lt;TextItems xsi:type="flex:TextItems" soapenc:arrayType="flex:TextItem[]" xmlns:flex="http://app.quinyx.com/soap/FlexForce"> &lt;item> &lt;tag>D&lt;/tag> &lt;ttext>$local.sub.etp.Ttext$&lt;/ttext> &lt;extCode>$local.sub.etp.ExtCode$&lt;/extCode> &lt;/item> &lt;/TextItems> &lt;/uri:wsdlUpdateTextItems> &lt;/soapenv:Body> &lt;/soapenv:Envelope>
               </token-text>
             </token-xml-parse>
           </arg-node-set>
         </do-set-local-variable>
         <!-- add operaiton data -->
         <do-trace-message>
           <arg-string>
             <token-text xml:space="preserve">=> </token-text>
             <token-xml-serialize>
               <token-local-variable name="local.otp.SOAP" />
             </token-xml-serialize>
           </arg-string>
         </do-trace-message>
         <do-append-xml-element expression=".." name="operation-data" />
         <!-- 
                <do-set-xml-attr expression="../operation-data" name="url">
                     <arg-string>
                          <token-local-variable name="local.otp.URL"/>
                     </arg-string>
                </do-set-xml-attr>-->
         <do-set-xml-attr expression="../operation-data" name="src-dn">
           <arg-string>
             <token-local-variable name="src-dn" />
           </arg-string>
         </do-set-xml-attr>
         <do-set-xml-attr expression="../operation-data" name="query-type">
           <arg-string>
             <token-text xml:space="preserve">update-store-costcenter:</token-text>
             <token-local-variable name="current-node" />
           </arg-string>
         </do-set-xml-attr>
         <do-clone-xpath dest-expression=".." src-expression="$local.otp.SOAP" />
       </arg-actions>
     </do-for-each>
     <do-strip-xpath expression="self::modify" />
   </actions>
 </rule>  

Monday, June 4, 2018

Reading Component type attribute values such Email Address





Read Email Attribute from Group:

<do-set-local-variable name="local.sub.etp.MailboxEmail" scope="policy"> <arg-node-set> <token-src-attr class-name="Group" name="EMail Address"> <arg-dn> <token-local-variable name="loca.sub.etp.Group"/> </arg-dn> </token-src-attr> </arg-node-set> </do-set-local-variable>



This would do following Output:


<nds dtdversion="4.0" ndsversion="8.x"> <source> <product edition="Advanced" version="4.5.6.0">DirXML</product> <contact>NetIQ Corporation</contact> </source> <output> <instance class-name="Group" qualified-src-dn="/N/A" src-dn="/N/A" src-entry-id="1026028"> <attr attr-name="EMail Address"> <value timestamp="1517759042#70" type="structured"> <component name="eMailType">3</component> <component name="eMailAddr">na@noname.com</component> </value> </attr> </instance> <status level="success"></status> </output> </nds>


Do Xpath to read the eMailAddr part from it:

<do-set-local-variable name="SingleEmailAddress" scope="policy"> <arg-string> <token-xpath expression="$local.sub.etp.MailboxEmail/component[@name='eMailAddr']"/> </arg-string> </do-set-local-variable>

Wednesday, December 20, 2017

NetIQ IDM - JDBC statemens using policy builder


Few examples of using JDBC statements using dirxml policies



On the Output policy:


Handling matching policies with operation-data support:


<rule> <description>[DB] Convert Query to DDL doc</description> <comment name="author" xml:space="preserve">Maqsood Ali Bhatti</comment> <comment name="version" xml:space="preserve">5</comment> <comment name="lastchanged" xml:space="preserve">Dec 20, 2017</comment> <conditions> <and> <if-operation mode="case" op="equal">query</if-operation> </and> </conditions> <actions> <do-append-xml-element expression=".." name="jdbc:statement" /> <do-append-xml-element expression="../jdbc:statement[last()]" name="jdbc:sql" /> <do-append-xml-text expression="../jdbc:statement/jdbc:sql[last()]"> <arg-string> <token-text xml:space="preserve">SELECT COUNT(*) FROM ALL_USERS WHERE USERNAME = '</token-text> <token-upper-case> <token-op-attr name="USERNAME" /> </token-upper-case> <token-text xml:space="preserve">'</token-text> </arg-string> </do-append-xml-text> <do-append-xml-element expression="../jdbc:statement[last()]" name="operation-data" /> <do-set-xml-attr expression="../jdbc:statement[last()]/operation-data[last()]" name="type"> <arg-string> <token-text xml:space="preserve">Matching</token-text> </arg-string> </do-set-xml-attr> <do-set-xml-attr expression="../jdbc:statement[last()]/operation-data[last()]" name="DN"> <arg-string> <token-op-attr name="USERNAME" /> </arg-string> </do-set-xml-attr> <do-strip-xpath expression="self::query" /> </actions> </rule>



Cathing Output of the Matching on Input Publisher


<rule> <description>Handle jdbc:result-set for matching objects</description> <comment name="author" xml:space="preserve">Maqsood Ali Bhatti</comment> <comment name="version" xml:space="preserve">2</comment> <comment name="lastchanged" xml:space="preserve">Dec 20, 20117</comment> <conditions> <and> <if-xpath op="true">self::jdbc:result-set/@jdbc:number-of-rows = 1</if-xpath> <if-xpath op="true">./operation-data[@type="Matching"]</if-xpath> </and> </conditions> <actions> <do-set-local-variable name="ASSO-VALUE" scope="policy"> <arg-string> <token-xpath expression="*//*[local-name()='value']/text()" /> </arg-string> </do-set-local-variable> <do-set-local-variable name="getDN" scope="policy"> <arg-string> <token-xpath expression="./operation-data/@DN" /> </arg-string> </do-set-local-variable> <do-trace-message> <arg-string> <token-text xml:space="preserve">add association</token-text> <token-local-variable name="getDN" /> </arg-string> </do-trace-message> <!-- association --> <do-if> <arg-conditions> <and> <if-local-variable mode="nocase" name="ASSO-VALUE" op="not-equal" /> <if-local-variable mode="nocase" name="ASSO-VALUE" op="equal">1</if-local-variable> </and> </arg-conditions> <arg-actions> <do-trace-message> <arg-string> <token-text xml:space="preserve">add association</token-text> </arg-string> </do-trace-message> <do-append-xml-element expression=".." name="instance" /> <do-set-xml-attr expression="../instance" name="class-name"> <arg-string> <token-text xml:space="preserve">User</token-text> </arg-string> </do-set-xml-attr> <do-set-xml-attr expression="../instance" name="src-dn"> <arg-string> <token-local-variable name="getDN" /> <token-text xml:space="preserve">:</token-text> <token-local-variable name="ASSO-VALUE" /> </arg-string> </do-set-xml-attr> <do-append-xml-element expression="../instance" name="association" /> <do-append-xml-text expression="../instance/association"> <arg-string> <token-local-variable name="getDN" /> <token-text xml:space="preserve">:</token-text> <token-local-variable name="ASSO-VALUE" /> </arg-string> </do-append-xml-text> </arg-actions> <arg-actions /> </do-if> <do-if> <arg-conditions> <and> <if-local-variable mode="nocase" name="ASSO-VALUE" op="not-equal" /> <if-local-variable mode="nocase" name="ASSO-VALUE" op="equal">0</if-local-variable> </and> </arg-conditions> <arg-actions> <do-trace-message> <arg-string> <token-text xml:space="preserve">NO MATCH</token-text> </arg-string> </do-trace-message> <do-break /> </arg-actions> <arg-actions /> </do-if> </actions> </rule>


Handle Add policies (Stored procedure with parameters)


<rule> <description>[DB] Convert Add to DDL doc</description> <comment name="author" xml:space="preserve">Maqsood Ali Bhatti</comment> <comment name="version" xml:space="preserve">5</comment> <comment name="lastchanged" xml:space="preserve">Dec 20, 2017</comment> <conditions> <and> <if-operation mode="case" op="equal">add</if-operation> </and> </conditions>
<actions> <do-set-local-variable name="local.otp.UserName" scope="policy"> <arg-string> <token-op-property name="prop.idm.UserName" /> </arg-string> </do-set-local-variable> <do-set-local-variable name="local.otp.UserPassword" scope="policy"> <arg-string> <token-op-property name="prop.idm.UserPassword" /> </arg-string> </do-set-local-variable> <do-append-xml-element expression=".." name="jdbc:statement" /> <do-append-xml-element expression="../jdbc:statement[last()]" name="jdbc:call-procedure" /> <do-set-xml-attr expression="../jdbc:statement[last()]/jdbc:call-procedure[last()]" name="jdbc:name"> <arg-string> <token-text xml:space="preserve">IDM.CREATEUSER</token-text> </arg-string> </do-set-xml-attr> <do-append-xml-element expression="../jdbc:statement[last()]/jdbc:call-procedure[last()]" name="jdbc:param" /> <do-append-xml-element expression="../jdbc:statement[last()]/jdbc:call-procedure[last()]/jdbc:param[last()]" name="jdbc:value" /> <do-append-xml-text expression="../jdbc:statement[last()]/jdbc:call-procedure[last()]/jdbc:param[last()]/jdbc:value[last()]"> <arg-string> <token-local-variable name="local.otp.UserName" /> </arg-string> </do-append-xml-text> <do-append-xml-element expression="../jdbc:statement[last()]/jdbc:call-procedure[last()]" name="jdbc:param" /> <do-append-xml-element expression="../jdbc:statement[last()]/jdbc:call-procedure[last()]/jdbc:param[last()]" name="jdbc:value" /> <do-append-xml-text expression="../jdbc:statement[last()]/jdbc:call-procedure[last()]/jdbc:param[last()]/jdbc:value[last()]"> <arg-string> <token-base64-decode charset="UTF-8"> <token-local-variable name="local.otp.UserPassword" /> </token-base64-decode> </arg-string> </do-append-xml-text> <do-strip-xpath expression="self::add" /> </actions> </rule>



About Me

My photo
Oslo, Oslo, Norway
love everything that talks binary!