2014-02-18 14:05 GMT+01:00 Jaime Cardoso <[email protected]>:
> On 17-02-2014 19:10, Clément OUDOT wrote:
>
>
>
>
> 2014-02-17 18:37 GMT+01:00 Jaime Cardoso <[email protected]>:
>
>> Hello lsc experts
>>
>>
> Hi Jaime,
>
>
>
>> I'm in the process of testing lsc and I'm pretty happy so far with the
>> results. Unfortunatelly, I've hit an issue that I don't knw how to bypass.
>> My source is an Active Directory and my destination is a proper LDAP
>> server.
>> I have, in the source system a group created with several members,
>> something like this:
>> dn: cn=grouptest, ou=AAA, ou=BBB, dc=test, dc=local
>> ...
>> member: cn=user1, ou=stuff, ou=WWW, ou=EEE, dc=test, dc=local
>> ...
>>
>> I'm able to sync the user into it's "right" place
>> cn=user1, ou=people, dc=new, dc=local
>>
>> and, I'm able to create the group also in it's "right" place:
>> cn=grouptest, ou=groups, dc=new, dc=local
>>
>> Now, How do I change the value of the member attribute to the user's new
>> location?
>> I don't need to perform any kind of checks, just a simple replace where
>> everything after the fist comma would be replaced by ou=groups, dc=new,
>> dc=local
>>
>> Any ideas (welcome better ways to do this also)
>>
>>
>
> in this case this is quite easy. Get all source member values in an
> array, and for each value, replace what you want. The result will be an
> array and will be pushed as multi values in the destination member
> attribute by LSC.
>
> A more complex example can be found here (for old LSC conf format, bu
> easy to port to the new one):
> http://lsc-project.org/wiki/documentation/1.1/tutorials/synchronizegroups
>
>
> Clément.
>
>
> Thanks for the help Clément, I was fearing such an anwer :(
> Coming from someone who's a total noob in javascript, I assume I'll put
> the code in a separate file and, in lsc.xml I'll invoke the script.
> Is that correct?
>
No, just use the script code inside a dataset, for example:
<dataset>
<name>street</name>
<policy>FORCE</policy>
<forceValues>
<string><![CDATA[
var street =
srcBean.getDatasetFirstValueById("userobm_address1");
if ( srcBean.getDatasetFirstValueById("userobm_address2") !=
"" ) {
street = street + "$" +
srcBean.getDatasetFirstValueById("userobm_address2");
}
if ( srcBean.getDatasetFirstValueById("userobm_address3") !=
"" ) {
street = street + "$" +
srcBean.getDatasetFirstValueById("userobm_address3");
}
street;
]]></string>
</forceValues>
</dataset>
>
> I was hoping I could do something like <delimiter>,</delimiter> and get
> the first part of the member value I get from AD and simply add as a string
> the "ou=people, dc=new,dc=local" part but wasn't able to make it work
>
>
Try :
var admembers = srcBean.getAttributeValuesById("member").toArray() ;
var members = new Array();
for (var i=0; i<members.length; i++ ) {
members[i] = admembers[i].replace('OLDBRANCH', 'ou=people,
dc=new,dc=local');
}
members;
_______________________________________________________________
Ldap Synchronization Connector (LSC) - http://lsc-project.org
lsc-users mailing list
[email protected]
http://lists.lsc-project.org/listinfo/lsc-users