Trigger a job through an different driver


Hi,

I am wondering if someone could tell me if it is possible to start a job
defined on one driver by a policy defined on an other driver.

We have a quite time consuming process on one driver and an scheduled
job on an different driver. For sure we can manually override the
schedule of the job by iManager selecting "Run now" in the job
configuration, but is there any way to select that "run now" of a given
job automatically through a driver policy or even through an external
process?

Thanks!


--
tschloesser
------------------------------------------------------------------------
tschloesser's Profile: https://forums.netiq.com/member.php?userid=3232
View this thread: https://forums.netiq.com/showthread.php?t=55485

  • There is probably a way via policy that I cannot remember, even if that
    means calling the Java class manually, but the easiest way is probably via
    the dxcmd command at a shell:


    dxcmd -startjob <job dn>


    --
    Good luck.

    If you find this post helpful and are logged into the web interface,
    show your appreciation and click on the star below...
  • tschloesser wrote:

    >
    > I am wondering if someone could tell me if it is possible to start a
    > job defined on one driver by a policy defined on an other driver.
    >
    > We have a quite time consuming process on one driver and an scheduled
    > job on an different driver. For sure we can manually override the
    > schedule of the job by iManager selecting "Run now" in the job
    > configuration, but is there any way to select that "run now" of a
    > given job automatically through a driver policy or even through an
    > external process?


    Yes definitely possible.

    Take a look at the starup policy included in most PCRS packages (for
    example Active Directory entitlements and exchange)

    There is a policy named: "Set Job Named Password value" - this can be
    easily adapted for your needs.

    It constructs a command of the form:

    -user <username> -password <userpwd> -setnamedpassword <job dn>
    ua-password <password>

    Your command would be instead:

    -user <username> -password <userpwd> -startjob <job dn>

    Sample code (untested)

    <rule>
    <description>Start job from another driver</description>
    <conditions/>
    <actions>
    <do-set-local-variable name="JOBDN" scope="policy">
    <arg-string>
    <token-text
    xml:space="preserve">PermissionOnboarding.driverb.</token-text>
    <token-parse-dn dest-dn-format="dot" length="-2"
    src-dn-format="slash" start="0">
    <token-global-variable name="dirxml.auto.driverdn"/>
    </token-parse-dn>
    </arg-string>
    </do-set-local-variable>
    <do-set-local-variable name="JOBDRIVERDN" scope="policy">
    <arg-string>
    <token-parse-dn dest-dn-format="slash" length="-2"
    src-dn-format="dot" start="0">
    <token-local-variable name="JOBDN"/>
    </token-parse-dn>
    </arg-string>
    </do-set-local-variable>
    <do-set-local-variable name="JOBADMIN" scope="policy">
    <arg-string>
    <token-src-attr name="Security Equals">
    <arg-dn>
    <token-local-variable name="JOBDRIVERDN"/>
    </arg-dn>
    </token-src-attr>
    </arg-string>
    </do-set-local-variable>
    <!-- Need to do this query with slash-form DN of JOBADMIN -->
    <do-set-local-variable name="PASSWORD" notrace="true" scope="policy">
    <arg-string>
    <token-src-attr name="nspmDistributionPassword">
    <arg-dn>
    <token-local-variable name="JOBADMIN"/>
    </arg-dn>
    </token-src-attr>
    </arg-string>
    </do-set-local-variable>
    <!-- Need to do this query with slash-form DN of UA ADMIN -->
    <!-- Now convert JOBADMIN to dot format -->
    <do-set-local-variable name="JOBADMIN" scope="policy">
    <arg-string>
    <token-parse-dn dest-dn-format="dot" src-dn-format="slash"
    start="1">
    <token-local-variable name="JOBADMIN"/>
    </token-parse-dn>
    </arg-string>
    </do-set-local-variable>
    <do-set-local-variable name="STARTJOBCMD" notrace="true"
    scope="policy">
    <arg-string>
    <token-text xml:space="preserve"> -user </token-text>
    <token-local-variable name="JOBADMIN"/>
    <token-text xml:space="preserve"> -password </token-text>
    <token-local-variable name="PASSWORD"/>
    <token-text xml:space="preserve"> -startjob '</token-text>
    <token-local-variable name="JOBDN"/>
    <token-text xml:space="preserve">'</token-text>
    </arg-string>
    </do-set-local-variable>
    <do-trace-message level="1" notrace="true">
    <arg-string>
    <token-text xml:space="preserve">STARTJOB_COMMAND: </token-text>
    <token-local-variable name="STARTJOBCMD"/>
    </arg-string>
    </do-trace-message>
    <do-set-local-variable name="setStartJOb" scope="policy">
    <arg-object>
    <token-xpath expression="jcmd:commandLine(string($STARTJOBCMD))"/>
    </arg-object>
    </do-set-local-variable>
    </actions>
    </rule>
  • On 07/03/16 13:34, tschloesser wrote:
    >
    > Hi,
    >
    > I am wondering if someone could tell me if it is possible to start a job
    > defined on one driver by a policy defined on an other driver.
    >
    > We have a quite time consuming process on one driver and an scheduled
    > job on an different driver. For sure we can manually override the
    > schedule of the job by iManager selecting "Run now" in the job
    > configuration, but is there any way to select that "run now" of a given
    > job automatically through a driver policy or even through an external
    > process?
    >
    > Thanks!
    >
    >


    You could figure out how to call com.novell.nds.dirxml.util.DxCommand
    (and document it), that would be a nicer solution that calling it as an
    external command.


    Casper
  • cpedersen;2422064 wrote:
    On 07/03/16 13:34, tschloesser wrote:
    >
    > Hi,
    >
    > I am wondering if someone could tell me if it is possible to start a job
    > defined on one driver by a policy defined on an other driver.
    >
    > We have a quite time consuming process on one driver and an scheduled
    > job on an different driver. For sure we can manually override the
    > schedule of the job by iManager selecting "Run now" in the job
    > configuration, but is there any way to select that "run now" of a given
    > job automatically through a driver policy or even through an external
    > process?
    >
    > Thanks!
    >
    >


    You could figure out how to call com.novell.nds.dirxml.util.DxCommand
    (and document it), that would be a nicer solution that calling it as an
    external command.


    Casper


    Like usual Geoffrey already had CS about this :)
    https://www.netiq.com/communities/cool-solutions/ism-even-easier-way-call-job-policy/

    <?xml version="1.0" encoding="UTF-8"?><policy xmlns:jcmd="">www.novell.com/.../com.novell.nds.dirxml.util.DxCommand">
    <rule>
    <description>[acme] Start a Job from Policy (1030)</description>
    <comment xml:space="preserve">Start a Job from policy example.</comment>
    <conditions>
    <or>
    <if-op-attr mode="nocase" name="twcTestingVersion" op="changing-to">1030</if-op-attr>
    </or>
    </conditions>
    <actions>
    <do-set-local-variable name="USERNAME" scope="policy">
    <arg-string>
    <token-src-attr name="Security Equals">
    <arg-dn>
    <token-global-variable name="dirxml.auto.driverdn"/>
    </arg-dn>
    </token-src-attr>
    </arg-string>
    </do-set-local-variable>
    <do-set-local-variable name="PASSWORD" scope="policy">
    <arg-string>
    <token-src-attr name="nspmDistributionPassword">
    <arg-dn>
    <token-local-variable name="USERNAME"/>
    </arg-dn>
    </token-src-attr>
    </arg-string>
    </do-set-local-variable>
    <do-set-local-variable name="USERNAME" scope="policy">
    <arg-string>
    <token-parse-dn dest-dn-format="dot" start="1">
    <token-local-variable name="USERNAME"/>
    </token-parse-dn>
    </arg-string>
    </do-set-local-variable>
    <do-set-local-variable name="JOB" scope="policy">
    <arg-string>
    <token-text xml:space="preserve">ToolkitRule.</token-text>
    <token-parse-dn dest-dn-format="dot" start="1">
    <token-global-variable name="dirxml.auto.driverdn"/>
    </token-parse-dn>
    </arg-string>
    </do-set-local-variable>
    <do-set-local-variable name="START-JOB" scope="policy">
    <arg-string>
    <token-xpath expression='jcmd:commandLine(" -user $USERNAME -password $PASSWORD -startjob $JOB")'/>
    </arg-string>
    </do-set-local-variable>
    </actions>
    </rule>
    </policy>
  • Hi Thorsten,

    On 07.03.2016 13:34, tschloesser wrote:
    >
    > Hi,
    >
    > I am wondering if someone could tell me if it is possible to start a job
    > defined on one driver by a policy defined on an other driver.


    I've used this in Validator:

    importPackage(com.novell.ldap);
    importPackage(com.novell.nds.dirxml.ldap);
    com.novell.nds.dirxml.ldap.DirXMLExtensions.initialize();

    /*
    * Cause the the DirXML Engine to start a job.
    * Rights needed:
    * Write access to the DirXML-AccessRun attribute on the target DirXML-Job
    object.
    * Returns: 0, if successful
    */
    function startJob(ldapHost, ldapPort, loginDN, password, jobDN) { var ld
    = new LDAPConnection(); var result; try {
    // connect to the server
    ld.connect(ldapHost, ldapPort);
    // bind to the server
    ld.bind(LDAPConnection.LDAP_V3, loginDN, password);
    // do extended request
    var request = new StartJobRequest(jobDN);
    var response = ld.extendedOperation(request);
    result = response.getResultCode();
    } catch (e) {
    result = e.toString();
    } finally {
    /* done, so disconnect */
    if (ld.isConnected()) {
    ld.disconnect();
    }
    }
    return result;
    }


    --
    Norbert