New Ranks & Badges For The Community!
Notice something different? The ranks and associated badges have gone "Star Fleet". See what they all mean HERE
Highlighted
Captain
Captain
1270 views

Connect to database with jdbc drivers rules

Jump to solution
Hello! I have a jdbc driver. Can I call a script in the rules settings on the publisher channel and the subscriber channel that will connect to a third-party database, for example mssql, take some parameters from the database and transfer them to the driver into a local variable, and then write this variable to the system to which the driver is configured? Does ecmascript support connecting to other databases?
1 Solution

Accepted Solutions
Highlighted
Vice Admiral
Vice Admiral

Hi

If you know of the option/function "com.novell.nds.dirxml.driver.cmd.DriverCmd". You can send XDS documents from one driver to a other.

Then setup a MSSQL driver, and on the "JDBC Driver" you can call / send a XDS document to the MSSQL Driveres Subscriber Command policy.

Code snip.... (See attached codeSnip.jpg)

<do-if>
<arg-conditions>
<and>
<if-local-variable mode="nocase" name="lv-DirXML-woType" op="equal">4</if-local-variable>
</and>
</arg-conditions>
<arg-actions>
<do-trace-message>
<arg-string>
<token-text xml:space="preserve">Sending XDS document to: $lv-driverdn$</token-text>
</arg-string>
</do-trace-message>
<do-set-local-variable name="lv-input-XDS" scope="policy">
<arg-node-set>
<token-xml-parse>
<token-local-variable name="lv-input"/>
</token-xml-parse>
</arg-node-set>
</do-set-local-variable>
<do-set-local-variable name="lv-sendcommandreplay" scope="policy">
<arg-node-set>
<token-xpath expression="dircmd:sendDriverCommand($lv-driverdn,$lv-input-XDS/nds)"/>
</arg-node-set>
</do-set-local-variable>
<do-set-local-variable name="lv-sendcommandreplaySerializeXML" scope="policy">
<arg-string>
<token-xml-serialize>
<token-local-variable name="lv-sendcommandreplay"/>
</token-xml-serialize>
</arg-string>
</do-set-local-variable>
<do-trace-message>
<arg-string>
<token-text xml:space="preserve">Send Command return: $lv-sendcommandreplaySerializeXML$</token-text>
</arg-string>
</do-trace-message>
</arg-actions>
<arg-actions/>
</do-if>

You should also be able to do this via ecmascript

/michael

View solution in original post

13 Replies
Highlighted
Vice Admiral
Vice Admiral

Hi

If you know of the option/function "com.novell.nds.dirxml.driver.cmd.DriverCmd". You can send XDS documents from one driver to a other.

Then setup a MSSQL driver, and on the "JDBC Driver" you can call / send a XDS document to the MSSQL Driveres Subscriber Command policy.

Code snip.... (See attached codeSnip.jpg)

<do-if>
<arg-conditions>
<and>
<if-local-variable mode="nocase" name="lv-DirXML-woType" op="equal">4</if-local-variable>
</and>
</arg-conditions>
<arg-actions>
<do-trace-message>
<arg-string>
<token-text xml:space="preserve">Sending XDS document to: $lv-driverdn$</token-text>
</arg-string>
</do-trace-message>
<do-set-local-variable name="lv-input-XDS" scope="policy">
<arg-node-set>
<token-xml-parse>
<token-local-variable name="lv-input"/>
</token-xml-parse>
</arg-node-set>
</do-set-local-variable>
<do-set-local-variable name="lv-sendcommandreplay" scope="policy">
<arg-node-set>
<token-xpath expression="dircmd:sendDriverCommand($lv-driverdn,$lv-input-XDS/nds)"/>
</arg-node-set>
</do-set-local-variable>
<do-set-local-variable name="lv-sendcommandreplaySerializeXML" scope="policy">
<arg-string>
<token-xml-serialize>
<token-local-variable name="lv-sendcommandreplay"/>
</token-xml-serialize>
</arg-string>
</do-set-local-variable>
<do-trace-message>
<arg-string>
<token-text xml:space="preserve">Send Command return: $lv-sendcommandreplaySerializeXML$</token-text>
</arg-string>
</do-trace-message>
</arg-actions>
<arg-actions/>
</do-if>

You should also be able to do this via ecmascript

/michael

View solution in original post

Highlighted
Admiral
Admiral

I'd suggest to use SendQueueEvent from Peter Lambrechtsen/Lothar instead. That way your driver does not bomb out if the destination driver is not running.

Original version: https://community.microfocus.com/t5/Identity-Manager-Tips/Sending-a-XDS-Message-from-one-driver-to-another/ta-p/1777175

Lothars updated: https://github.com/lhaeger/dxqueue

 

 

Highlighted
Knowledge Partner Knowledge Partner
Knowledge Partner

Does sendQueueEvent treata the result as a Migrate request?  The Javadoc seems to imply that.  Or am I misreading it?  One interpretation might be thata  Querys results would be turned into a migrate but a modify or add would flow through...

 

constructQueueEvent

public DxWire.DxWireData constructQueueEvent(String driverDN,
                                             byte[] xdsDocumentBytes)

Construct a wire-format buffer to send an query document to a DirXML driver to cause the engine to migrate all objects returned as the result of the query into DirXML.

 

Parameters: driverDN - DN of driver to which the query document is to be sent. xdsDocumentBytes - bytes containing serialized XML document. Returns: DxWireData instance containing wire information.

0 Likes
Highlighted
Admiral
Admiral

Very good question, which I can't answer.

The difference between sendDriverCommand and sendQueueEvent is that with 'sendQueueEvent' the event is send to the cache, and processed when the driver is running. Where a sendDriverCommand will fail if the driver is not running.

This of cause also mean that you can't use sendQueueEvent if you depend on the output of the command.

Highlighted
Knowledge Partner Knowledge Partner
Knowledge Partner

That is an excellent counter point.

I am using Lothar's dxqueue JS right now with migrateApp() which is working very nicely.

But now I need to send events to process.  (SOAP driver, one Add, generates two more modifies.  Want to process the add, and strip out the modifies, and dump them in the queue for processing after this Add is complete.   Just abouot to test with sendQueuedEvent().   Hoping that add|modify means process, query results mean migrate or somesuch.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Geoffry, is this add + modify in the same SOAP driver?

I had a similar use case in a REST driver that connects to an service that only supports PUT for modifications. I had to first create an object via POST, read its initial state via GET and then update the attributes IDM is authoritative for via PUT.

In a command transform policy you can submit the add as direct command via the destCommandProcessor and let the modify commands proceed normally if the add was successful:

<do-set-local-variable name="lvAddResult" scope="policy">
    <arg-node-set>
        <token-xpath expression="cmd:execute($destCommandProcessor, $current-op)"/>
    </arg-node-set>
</do-set-local-variable>
<do-if>
    <arg-conditions>
        <and>
            <if-xpath op="not-true">$lvAddResult/nds/output/status[@level='success']</if-xpath>
        </and>
    </arg-conditions>
    <arg-actions>
        <!-- error handling -->
    </arg-actions>
    <arg-actions/>
</do-if>

 

--
Norbert
Highlighted
Knowledge Partner Knowledge Partner
Knowledge Partner

Now that is clever. I did not think of that...  Make event #1 go first, direct, then let the rest process naturally.

 

You sir, are a clever fellow.  however in my case, I am pretty sure I will have three events, so I would still have an issue with event #2 and #3 still needing to be split.

In my case, #1, has attributes that cannot be set in the main SOAP call so I need to split them off to send via SOAP #2 and SOAP #3. 

My current plan is let #1 flow, and dump #2 and 3 in the queue.  Now this has a major hole, in that if a modify of one of those attributes happen after the <add> is sent, but before it finishes processing the add, I could be sticking this in the queue after the event,.

 

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

With SubmitEvents, the normal Subscriber channel rules, starting with the Filter and Event Transformation, apply. With SubmitCommand, processing starts at the Command Transformation Policyset. Both operations have a response.

QueueEvent is fire and forget.

--
Norbert
Highlighted
Knowledge Partner Knowledge Partner
Knowledge Partner

And migrateApp is a query, whose <instance> result is converted to a <sync> right?

0 Likes
Highlighted
Captain
Captain
Thanks for the help! Your method works great for me. I have started the process of transferring data between drivers. It's fine! But there was a question about the com.novell.nds.dirxml.driver.cmd.DriverCmd function. I connected it like this xmlns: dircmd = "http://www.novell.com/nxsl/java/com.novell.nds.dirxml.driver.cmd.DriverCmd. And I need it to work without an Internet connection. How can I download it locally or is it already available locally and need to somehow register the connection differently?
0 Likes
Highlighted
Vice Admiral
Vice Admiral

Hi

It's already available locally. See jpg file to declare it

Please see the "disadvantages", that other in this thread is mention

/Michael

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.