EvilDobe Absent Member.
Absent Member.
284 views

Unique Name noun


I have recently learned about the Unique Name token and, for the most
part, got it working properly. The only caveat is that we have generic
userIDs that are one letter and five numbers and if it finds a duplicate
value it adds 00000n at the end. Is there a way to have it look for
another set of five numbers instead of appending a number at the end?


--
EvilDobe
------------------------------------------------------------------------
EvilDobe's Profile: http://forums.novell.com/member.php?userid=103503
View this thread: http://forums.novell.com/showthread.php?t=454267

Labels (1)
0 Likes
9 Replies
Knowledge Partner
Knowledge Partner

Re: Unique Name noun

On 4/3/2012 3:16 PM, EvilDobe wrote:
>
> I have recently learned about the Unique Name token and, for the most
> part, got it working properly. The only caveat is that we have generic
> userIDs that are one letter and five numbers and if it finds a duplicate
> value it adds 00000n at the end. Is there a way to have it look for
> another set of five numbers instead of appending a number at the end?


You could chain it. Try the first time, setting the value into a variable.

XPATH string-length($Var)=6 then try again, otherwise proceed...

I do not recall there being any variables that explain/hint at what the
token did. So you would have to work with the way it is designed, I
suppose.


0 Likes
EvilDobe Absent Member.
Absent Member.

Re: Unique Name noun


I thought about the variable option but I am unclear on how to make it
try again, or keep trying, until a unique value is generated.


--
EvilDobe
------------------------------------------------------------------------
EvilDobe's Profile: http://forums.novell.com/member.php?userid=103503
View this thread: http://forums.novell.com/showthread.php?t=454267

0 Likes
Knowledge Partner
Knowledge Partner

Re: Unique Name noun

On 4/3/2012 4:36 PM, EvilDobe wrote:
>
> I thought about the variable option but I am unclear on how to make it
> try again, or keep trying, until a unique value is generated.


Ok, so on unavailable is your friend. Either return nothing, (and
increment to never) or increment and count the string length and do it
again. MIght want a third try with a different pattern, but you could
still exhaust that in theory.


0 Likes
Anonymous_User Absent Member.
Absent Member.

Re: Unique Name noun

Is it just five random numbers that you need to generate?
If so, you can use the generate password token and point it to a password policy that has a min and
max of 5 chars and only allows numbers. Then iterate as needed until you have a unique one.

On 4/3/2012 3:36 PM, EvilDobe wrote:
>
> I thought about the variable option but I am unclear on how to make it
> try again, or keep trying, until a unique value is generated.
>
>


0 Likes
EvilDobe Absent Member.
Absent Member.

Re: Unique Name noun


I need to generate a 6 character userID with 1 alpha-character & 5
numeric-characters (example: x54689). If it finds a unique value
everything works fine but if it finds a duplicate it either dumps the CN
or it appends a number at the end making it 7 characters in length.
What I want to happen is, seemingly, simple..
Generate 5 numbers, put a character in front of it, check if it's
available.
If available then use it. If not start over with 5 different numbers.


--
EvilDobe
------------------------------------------------------------------------
EvilDobe's Profile: http://forums.novell.com/member.php?userid=103503
View this thread: http://forums.novell.com/showthread.php?t=454267

0 Likes
EvilDobe Absent Member.
Absent Member.

Re: Unique Name noun


Sorry but I'm a n00b at this but in regards to the "pattern" that you
fill in for the Unique Name token.. If I put 1 pattern in there it uses
that and then fails to the counter or errors. If I put 5 patterns in
there does it check the first for uniqueness & use it if it works or
does it check each each pattern for uniqueness & use the last one in the
pattern regardless of whether or not the others worked?


--
EvilDobe
------------------------------------------------------------------------
EvilDobe's Profile: http://forums.novell.com/member.php?userid=103503
View this thread: http://forums.novell.com/showthread.php?t=454267

0 Likes
jwilleke Honored Contributor.
Honored Contributor.

Re: Unique Name noun

On 2012-04-04 17:46:01 +0000, EvilDobe said:

> Sorry but I'm a n00b at this but in regards to the "pattern" that you
> fill in for the Unique Name token.. If I put 1 pattern in there it uses
> that and then fails to the counter or errors. If I put 5 patterns in
> there does it check the first for uniqueness & use it if it works or
> does it check each each pattern for uniqueness & use the last one in the
> pattern regardless of whether or not the others worked?


We too ran into this issue and created a way to acomplish it.
http://ldapwiki.willeke.com/wiki/Unique%20Value%20Finder


--

Thank You for your help!

-jim
Jim Willeke
0 Likes
Anonymous_User Absent Member.
Absent Member.

Re: Unique Name noun

On 4/4/12 11:46 AM, EvilDobe wrote:
>
> Sorry but I'm a n00b at this but in regards to the "pattern" that you
> fill in for the Unique Name token.. If I put 1 pattern in there it uses
> that and then fails to the counter or errors. If I put 5 patterns in
> there does it check the first for uniqueness& use it if it works or
> does it check each each pattern for uniqueness& use the last one in the
> pattern regardless of whether or not the others worked?
>
>

RTFM
http://www.novell.com/documentation/idm401/policy_designer/data/bookinfo.html

Here's one way to think about doing it:
<rule>
<description>Example</description>
<conditions>
<and/>
</conditions>
<actions>
<do-set-local-variable name="letter" scope="policy">
<arg-string>
<token-text>However you pick the letter</token-text>
</arg-string>
</do-set-local-variable>
<do-while>
<arg-conditions>
<and>
<if-local-variable mode="regex" name="name"
op="not-equal">.+</if-local-variable>
</and>
</arg-conditions>
<arg-actions>
<do-set-local-variable name="number" scope="policy">
<arg-string>
<token-text>However you pick a number to try</token-text>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="name" scope="policy">
<arg-string>
<token-unique-name counter-pad="false" counter-pattern="last"
counter-use="never" name="cn" on-unavailable="ignore">
<arg-string>
<token-local-variable name="letter"/>
<token-local-variable name="number"/>
</arg-string>
</token-unique-name>
</arg-string>
</do-set-local-variable>
</arg-actions>
</do-while>
</actions>
</rule>

In a nutshell - pick a letter and then loop picking a number to try and
trying it without a counter and ignoring a failure. End the loop when a
non-empty value has been returned.

--
Shon
0 Likes
EvilDobe Absent Member.
Absent Member.

Re: Unique Name noun


Shon - thank you for the response. I have been googling all over &
couldn't find that manual and your example made A LOT of sense to me.
This is what I came up with.
<rule>
<description>Example - Tweaked</description>
<conditions>
<and/>
</conditions>
<actions>
<do-while>
<arg-conditions>
<and>
<if-local-variable mode="regex" name="propCN"
op="not-equal">.+</if-local-variable>
</and>
</arg-conditions>
<arg-actions>
<do-set-local-variable name="propCN" scope="policy">
<arg-string>
<token-unique-name counter-pad="false" counter-use="never"
name="CN" on-unavailable="ignore" scope="subtree">
<arg-string>
<token-text xml:space="preserve">u</token-text>
<token-generate-password
policy-dn="..\..\..\..\Security\Password Policies\Test limit 5"/>
</arg-string>
</token-unique-name>
</arg-string>
</do-set-local-variable>
</arg-actions>
</do-while>
<do-set-dest-attr-value name="CN">
<arg-value type="string">
<token-local-variable name="propCN"/>
</arg-value>
</do-set-dest-attr-value>
</actions>
</rule>


--
EvilDobe
------------------------------------------------------------------------
EvilDobe's Profile: http://forums.novell.com/member.php?userid=103503
View this thread: http://forums.novell.com/showthread.php?t=454267

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.