VJendrusch Absent Member.
Absent Member.
579 views

Parsing of CN and returning the parsed value

Hi all,

i am looking for a solution to build into an Bidirectional LDAP Driver.
The source CN consists of multiple informations that are not spearated by a certain character or something like that. The only way to find that part i need is with an complex regex. I only need the part the regex found and if there is also an leading "-" i have to get rid of it and use the rest of the result to write it back into a local variable.
What do i want with that?
I have an source CN like that: Blah-All-467777-78-NYC or Blah-2490-4712-NYC...
I also have an matching but not (yet) associated (target-) object like: Blah-all.467777-78.Groups.STUDIO.NYC.US.AME or for the other one: Blah-2940.4712.Groups.Studio.NYC.US.AME.
So i have to parse the source CN with an regex and use the find to construct a new DN.
I think it has to be ECMA but i am not familar with it.
Any ideas?
Thx in advance
Volker:cool:
Labels (1)
0 Likes
8 Replies
Knowledge Partner
Knowledge Partner

Re: Parsing of CN and returning the parsed value

I have an source CN like that: Blah-All-467777-78-NYC or Blah-2490-4712-NYC...


Volker,
Could you provide an example of your"source" information and expected result?

I'm a little bit "lost" in your explanation. 😞
Do you want to remove all "-" characters or only leading "-"?
0 Likes
Knowledge Partner
Knowledge Partner

Re: Parsing of CN and returning the parsed value

On 06/23/2018 08:34 PM, al b wrote:
>
>> I have an source CN like that: Blah-All-467777-78-NYC or
>> Blah-2490-4712-NYC...

>
> Volker,
> Could you provide an example of your"source" information and expected
> result?
>
> I'm a little bit "lost" in your explanation. 😞
> Do you want to remove all "-" characters or only leading "-"?


Agreed, and also could you explain why the DNs are dotted? You mentioned
this is an LDAP driver, meaning the DNs should probably be in LDAP format.

Otherwise, just generally looking at this it appears that the first four
portion of the source CN are the first parts of the target DN, though
those dots make me wonder how valid that assumption is. The last part of
the source CN appears to be, in these two examples anyway, part of the DN
down the line (NYC).

In addition to the questions above, it may be useful to answer whether or
not object names are unique throughout the directory. Ideally doing some
slight transformation on the source DN and then searching globally in the
target would be nice and easy. If you need to come up with one, or two,
or a few hundred placement actions based on containers and such, then it
becomes a bit more work, and probably worth a mapping table.

The more examples, and the more varied and concrete the examples, the better.

--
Good luck.

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

If you want to send me a private message, please let me know in the
forum as I do not use the web interface often.
0 Likes
Knowledge Partner
Knowledge Partner

Re: Parsing of CN and returning the parsed value

On 6/23/2018 10:34 PM, al b wrote:
>
>> I have an source CN like that: Blah-All-467777-78-NYC or
>> Blah-2490-4712-NYC...

>
> Volker,
> Could you provide an example of your"source" information and expected
> result?
>
> I'm a little bit "lost" in your explanation. 😞
> Do you want to remove all "-" characters or only leading "-"?


And how does we want to turn this into a DN.

I have often taken a DN, replaced the backslash with a dash to build an
object name with the DN path in the name.


0 Likes
Knowledge Partner
Knowledge Partner

Re: Parsing of CN and returning the parsed value

On 6/23/2018 3:24 PM, VJendrusch wrote:
>
> Hi all,
>
> i am looking for a solution to build into an Bidirectional LDAP Driver.
> The source CN consists of multiple informations that are not spearated
> by a certain character or something like that. The only way to find that
> part i need is with an complex regex. I only need the part the regex
> found and if there is also an leading "-" i have to get rid of it and
> use the rest of the result to write it back into a local variable.
> What do i want with that?
> I have an source CN like that: Blah-All-467777-78-NYC or
> Blah-2490-4712-NYC...
> I also have an matching but not (yet) associated (target-) object like:
> Blah-all.467777-78.Groups.STUDIO.NYC.US.AME or for the other one:
> Blah-2940.4712.Groups.Studio.NYC.US.AME.
> So i have to parse the source CN with an regex and use the find to
> construct a new DN.
> I think it has to be ECMA but i am not familar with it.


You could use the split token to convert the Blah-All-467777-78-NYC
string into a nodeset of values, then Join that nodeset, with a dot or
back slash (Depending if you need to reverse the order or not.).




0 Likes
VJendrusch Absent Member.
Absent Member.

Re: Parsing of CN and returning the parsed value

Okay, i try to clarify my case:
i have a group originally named Blah-7017-18 with an DN like: Blah-7017-18.7017-20.Groups.Studio.NYC.US.AME.MyCompany, it is synchronisized into AD with an new CN: Blah-7017-18-7017-20-NYC.
The next group is may be Blah-Group with an DN like Blah-Group.345678-90.Groups.Studio.WDC.US.AME.MyCompany, in AD: Blah-Group-345678-90-WDC
And the next: 3010-Blah-34 with the DN: 3010-Blah-34.8-Grp.Groups.Studio.NYC.US.AME.MyCompany, AD: 3010-Blah-34-8-grp-NYC
Out of the last part i can reconstruct the former part of the DN that is no problem. But i need to reconstruct the whole original DN out of the remaining information.
The problem is there is no indicator where the originally CN ends because there is now schema to detect it. You can´t count the hyphens because there can be 1 or more or even no hyphen present.
The reqex i wrote covers the only way to separate the cn from the other information. The object has to be in an ou which is named 8-grp, 1234, 123456, 1234-56, 123456-78 ... but not in an OU which starts not with a digit.
With the exception of 8-grp the OUs have to consists of digits before the last part of the cn (-NYC, -WDC...). After cutting of this last part the value that remains is the original CN and the information in which OU the object was stored.

The part with getting rid of the hyphen meant that if i run the regex against my examples (not 8-grp) there is a hyphen at the beginning that i don´t need.

Greetings
Volker
0 Likes
Knowledge Partner
Knowledge Partner

Re: Parsing of CN and returning the parsed value

VJendrusch;2483012 wrote:
Okay, i try to clarify my case:
i have a group originally named Blah-7017-18 with an DN like: Blah-7017-18.7017-20.Groups.Studio.NYC.US.AME.MyCompany, it is synchronisized into AD with an new CN: Blah-7017-18-7017-20-NYC.
The next group is may be Blah-Group with an DN like Blah-Group.345678-90.Groups.Studio.WDC.US.AME.MyCompany, in AD: Blah-Group-345678-90-WDC
And the next: 3010-Blah-34 with the DN: 3010-Blah-34.8-Grp.Groups.Studio.NYC.US.AME.MyCompany, AD: 3010-Blah-34-8-grp-NYC
Out of the last part i can reconstruct the former part of the DN that is no problem. But i need to reconstruct the whole original DN out of the remaining information.
The problem is there is no indicator where the originally CN ends because there is now schema to detect it. You can´t count the hyphens because there can be 1 or more or even no hyphen present.
The reqex i wrote covers the only way to separate the cn from the other information. The object has to be in an ou which is named 8-grp, 1234, 123456, 1234-56, 123456-78 ... but not in an OU which starts not with a digit.
With the exception of 8-grp the OUs have to consists of digits before the last part of the cn (-NYC, -WDC...). After cutting of this last part the value that remains is the original CN and the information in which OU the object was stored.

The part with getting rid of the hyphen meant that if i run the regex against my examples (not 8-grp) there is a hyphen at the beginning that i don´t need.

Greetings
Volker


Hi Volker,
Maybe this is stupid question, but if you create AD groups based on eDir groups, you suppose to have associations between eDir and AD objects.
You can resolve "original" name based on known AD name.
0 Likes
Knowledge Partner
Knowledge Partner

Re: Parsing of CN and returning the parsed value

On 6/25/2018 10:54 AM, al b wrote:
>
> VJendrusch;2483012 Wrote:
>> Okay, i try to clarify my case:
>> i have a group originally named Blah-7017-18 with an DN like:
>> Blah-7017-18.7017-20.Groups.Studio.NYC.US.AME.MyCompany, it is
>> synchronisized into AD with an new CN: Blah-7017-18-7017-20-NYC.
>> The next group is may be Blah-Group with an DN like
>> Blah-Group.345678-90.Groups.Studio.WDC.US.AME.MyCompany, in AD:
>> Blah-Group-345678-90-WDC
>> And the next: 3010-Blah-34 with the DN:
>> 3010-Blah-34.8-Grp.Groups.Studio.NYC.US.AME.MyCompany, AD:
>> 3010-Blah-34-8-grp-NYC
>> Out of the last part i can reconstruct the former part of the DN that is
>> no problem. But i need to reconstruct the whole original DN out of the
>> remaining information.
>> The problem is there is no indicator where the originally CN ends
>> because there is now schema to detect it. You can�t count the hyphens
>> because there can be 1 or more or even no hyphen present.
>> The reqex i wrote covers the only way to separate the cn from the other
>> information. The object has to be in an ou which is named 8-grp, 1234,
>> 123456, 1234-56, 123456-78 ... but not in an OU which starts not with a
>> digit.
>> With the exception of 8-grp the OUs have to consists of digits before
>> the last part of the cn (-NYC, -WDC...). After cutting of this last part
>> the value that remains is the original CN and the information in which
>> OU the object was stored.
>>
>> The part with getting rid of the hyphen meant that if i run the regex
>> against my examples (not 8-grp) there is a hyphen at the beginning that
>> i don�t need.
>>
>> Greetings
>> Volker

>
> Hi Volker,
> Maybe this is stupid question, but if you create AD groups based on eDir
> groups, you suppose to have associations between eDir and AD objects.
> You can resolve "original" name based on known AD name.


That is a pretty good.

To clarify, Set Local Variable, and in the string builder, use the
Resolve verb token, Association to DN, in the destination, (assuming you
are in the Sub channel) and then provide the Association token as the
noun for the verb.

Then you can parseDN it to get whatever you need out of the name or the
location in AD.
0 Likes
Knowledge Partner
Knowledge Partner

Re: Parsing of CN and returning the parsed value

VJendrusch;2482955 wrote:
Hi all,

i am looking for a solution to build into an Bidirectional LDAP Driver.
The source CN consists of multiple informations that are not spearated by a certain character or something like that. The only way to find that part i need is with an complex regex. I only need the part the regex found and if there is also an leading "-" i have to get rid of it and use the rest of the result to write it back into a local variable.
What do i want with that?
I have an source CN like that: Blah-All-467777-78-NYC or Blah-2490-4712-NYC...
I also have an matching but not (yet) associated (target-) object like: Blah-all.467777-78.Groups.STUDIO.NYC.US.AME or for the other one: Blah-2940.4712.Groups.Studio.NYC.US.AME.
So i have to parse the source CN with an regex and use the find to construct a new DN.
I think it has to be ECMA but i am not familar with it.
Any ideas?
Thx in advance
Volker:cool:


I don't understand why you're doing this, but doing it should be easy enough.

You can get the CN in to a local variable:


set local variable foo = source-attribute CN


Be careful if CN can be multivalued in this system. Maybe use source-name there instead, assuming your source is using CN for the naming attribute. Or get the DN and parse the name off of it.

Then you can apply a regex to it:


<do-set-local-variable name="bar" scope="policy">
<arg-string>
<token-replace-all regex="(?-i)[^A-Z]" replace-with="">
<token-local-variable name="foo"/>
</token-replace-all>
</arg-string>
</do-set-local-variable>


Put your RegEx in there, of course. Then you can go do whatever complicated things you need to do with this local variable to build a DN or whatever.

Does that not do what you need?
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.