Anonymous_User Absent Member.
Absent Member.
316 views

import jpegs into jpegPhoto


Hi Guys
Given a filepath to a jpeg i can do this with ice engine and ldapmodify
command line and it puts the jpeg straight into an octet string in
jpegPhoto - which then goes nicely through my AD driver into jpegPhoto
in AD- but i want to trigger it on specific user objects in the edir
(8855) by attribute through a command transform.
any ideas how i can get my idm (351/361) engines (netware linux or
windows) to recognise the jpeg from a filepath and pull it straight into
jpegPhoto?
Am i looking at xpath to trigger external java code?
thanks for any ideas
Mike


--
zzalsmre
------------------------------------------------------------------------
zzalsmre's Profile: https://forums.netiq.com/member.php?userid=390
View this thread: https://forums.netiq.com/showthread.php?t=46057

Labels (1)
0 Likes
3 Replies
jtl1 Absent Member.
Absent Member.

Re: import jpegs into jpegPhoto

Hi,

You can use the following ecma script (taken from NOVLLIBAJC-JS):

importPackage(java.io);
importClass(Packages.com.novell.xml.util.Base64Codec);
importClass(java.lang.System);

var JString = java.lang.String; // don't hide the built in String object

/**
* Read an image from a file and return the content as Base64 encoded string.
*
* @param {String} imageFileName name of the image (or other binary) file
* @param {boolean} wrap wrap the result <i>optional: defaults to false</i>
*
* @type String
* @return Base64 encoded content of the image file
*/
function readImage(imageFileName, wrap) {
var picBase64 = "";
var fis;
try {
fis = new FileInputStream(imageFileName);
var bis = new BufferedInputStream(fis);
var baos = new ByteArrayOutputStream() ;
for(var buf = -1; (buf = bis.read()) != -1;)
baos.write(buf);
fis.close();
baos.flush();
picBase64 = new JString(Base64Codec.encode(baos.toByteArray(), Boolean(wrap)));
}
catch (ioe)
{
println(ioe);
}
finally
{
if (fis)
{
fis.close();
}
}
return picBase64;
}

/**
* print the argument followed by a newline
*
* @private
*
* @param arg the argument
*
* @type void
*/
function println(arg)
{
System.out.println(String(arg));
}

In the policybuilder you can use xpath to set a local variable (or source/dest attribute value) to the result from an ecmascript:

<do-set-local-variable name="b64EncodedJPG" scope="policy">
<arg-node-set>
<token-xpath expression="es:readImage('myNicePicture.jpeg')"/>
</arg-node-set>
</do-set-local-variable>

Best regards,
Tobias

On 2012-11-01 12:24, zzalsmre wrote:
>
> Hi Guys
> Given a filepath to a jpeg i can do this with ice engine and ldapmodify
> command line and it puts the jpeg straight into an octet string in
> jpegPhoto - which then goes nicely through my AD driver into jpegPhoto
> in AD- but i want to trigger it on specific user objects in the edir
> (8855) by attribute through a command transform.
> any ideas how i can get my idm (351/361) engines (netware linux or
> windows) to recognise the jpeg from a filepath and pull it straight into
> jpegPhoto?
> Am i looking at xpath to trigger external java code?
> thanks for any ideas
> Mike
>
>


0 Likes
Anonymous_User Absent Member.
Absent Member.

Re: import jpegs into jpegPhoto

On 01.11.2012 12:24, zzalsmre wrote:
>
> Hi Guys
> Given a filepath to a jpeg i can do this with ice engine and ldapmodify
> command line and it puts the jpeg straight into an octet string in
> jpegPhoto - which then goes nicely through my AD driver into jpegPhoto
> in AD- but i want to trigger it on specific user objects in the edir
> (8855) by attribute through a command transform.
> any ideas how i can get my idm (351/361) engines (netware linux or
> windows) to recognise the jpeg from a filepath and pull it straight into
> jpegPhoto?


Either via ECMAScript (as Tobias explained & also documented here)

https://www.netiq.com/documentation/idm402/policy_designer/data/ecmaexamples.html#b7uzaqp

or via the Delimited Text Driver (note the license for DLT is not
included in Base IDM License)- but has some solid advantages over the
ecmascript option.

https://www.netiq.com/documentation/idm402drivers/delimited/data/b6f4txa.html
0 Likes
Anonymous_User Absent Member.
Absent Member.

Re: import jpegs into jpegPhoto


went for the ecmascript - works first time
thanks to you both


--
zzalsmre
------------------------------------------------------------------------
zzalsmre's Profile: https://forums.netiq.com/member.php?userid=390
View this thread: https://forums.netiq.com/showthread.php?t=46057

0 Likes
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.