Overview#

The token-unique-name does a good job but we were in need of a method that could:

Although we wrote for use with Novell's IDM and User Provisioning products (User App) we are sure there are uses.

Use Entirely at Your Own Risk Services.willeke.biz nor anyone else is responsible if you use a tool or any information on this site and causes damages to anyone or anything! You are required to read Our Standard Disclaimer

Features#

  • Generate a non-existing Unique value for any string attribute
  • Numeric or Alphanumeric sequences
  • Uses prefixes or not
  • All parameters can be stored in a properties file or overridden at when called.
  • Good way to implement Best Practices For Unique Identifiers.

Allowable Arguments#

Alphanumeric Generation#

The alphanumeric generator uses the 36 possible values for unique values consisting of the English alphabet and the numbers 0-9.

Anomalies#

All values are returned in uppercase.

You cannot specify a startValue with Alphanumeric Generation.

Allowable Arguments are: #

  • String attributeForUniqueValue - The attribute name for to find a unique value
  • String preFix - The prefix desired (can be empty)
  • String startValue - This value will be ignored. When the useAlpha=True, All generated ids have the same length (prefixed and padded with 0's on the left), which is determined by the maxLength parameter.
  • int maxTries - Maximum number to try. Put a value here or you could search forever. You can make it big, 10000000.
  • int maxLength - Total length of the attribute, including any prefix if used.
  • boolean counterPad - Left-pad with zeros. If a preFix is used, the padding will be between the preFix and sequence
  • boolean useAlpha - Must be true to do alphanumeric generation.
  • String dummy - Used to create a unique call signature as some products are not able to use methods with the same parameter count with different types. Nothing is done with this value.

Numeric Generation#

Anomalies#

When using counterPad, you can not specify a startValue with Numeric Generation.

When specifying a startValue and a preFix, the maxLength is ignored.

Allowable Arguments are: #

  • String attributeForUniqueValue - The attribute name for to find a unique value
  • String preFix - The prefix desired (can be empty can use "null" as a String)
  • String startValue - The generation will start at this initial value. Must be numeric value. NOTE: Not valid if preFix and counterPad parameters are specified.
  • int maxLength - Total length of the attribute, including any prefix if used.
  • int maxTries - Maximum number to try. Put a value here or you could search forever. You can make it big, 10000000.
  • boolean counterPad (true or false) - Left-pad with zeros. If a preFix is used, the padding will be between the preFix and sequence
  • boolean useAlpha (true or false) - must be false to do numeric generation.
  • String dummy - Used to create a unique call signature as some products are not able to use methods with the same parameter count with different types. Nothing is done with this value.

Calling from another Java Application#

The parameters are positional specific.

Any values not specified will be obtained from the uniquevaluefinder.properties file.

You will call:

public static String findUniqueValue()
or
public static String findUniqueValue(String attributeForUniqueValue)
or
public static String findUniqueValue(String attributeForUniqueValue, String preFix)
or
public static String findUniqueValue(String attributeForUniqueValue, String preFix, String valueStart,  int maxLength,int maxTries, boolean counterPad, boolean useAlpha)
or (Note: all String value types, use "null" for empty preFix or startValue arguments)
public static String findUniqueValue(String attributeForUniqueValue, String preFix, String valueStart,  String maxLength, String maxTries, String counterPad, String useAlpha, String dummy)

Command-Line#

When passing command-line arguments, use "null" for empty preFix or startValue arguments.

One Arguments#

Calling the program with one arguments will use all the other values from the uniquevaluefinder.properties file.
attributeForUniqueValue  

Two Arguments#

Calling the program with no arguments will use all the values from the uniquevaluefinder.properties file.
 attributeForUniqueValue  preFix 

Six Arguments#

Calling the program with no arguments will use all the values from the uniquevaluefinder.properties file.
 attributeForUniqueValue  preFix startValue maxTries maxLength  counterPad

Seven Arguments#

Calling the program with no arguments will use all the values from the uniquevaluefinder.properties file.
 attributeForUniqueValue  preFix startValue maxTries maxLength  counterPad useAlpha 

Eight Arguments#

Calling the program with no arguments will use all the values from the uniquevaluefinder.properties file.
 attributeForUniqueValue  preFix startValue maxTries maxLength  counterPad useAlpha dummy

Example#

java -jar debuguniquevaluefinder.jar "uidNumber" "null" "1001" "5" "65000" "false" "false" "dummy"

uniquevaluefinder.properties#

The properties file is used to set the LDAP connection parameters and can be used to set all other values.

Any value supplied on the command-line or via a method call, overrides the value(s) in the uniquevaluefinder.properties file.

##############################
# LDAP connection Properties
##############################
searchbase=ou=people,dc=yourcompany,dc=com
ldaphost=ldap.yourcompany.com
ldapport = 636
logindn=cn=admin,dc=yourcompany,dc=com
password=<secret>
connectvia=ssl

##############################
# Default Values
##############################
prefix=A48
maxtries=100000
attributeforuniquevalue=CN
counterpad=false
startvalue=U46Z99
maxlength=6
usealpha=true

##############################
# Do not Change following lines.
# for tests only
##############################
mytestflag=false
printflag=false

WARNING#

Do not set the values for the following parameters in uniquevaluefinder.properties to "true" in production.
  • mytestflag=true - This will dump all the possible values to the stout. No LDAP searches are performed.
  • printflag=true - prints miscellaneous troubleshooting information to the stout.

LDAP Connection#

The LDAP connection is maintained until one of the following occurs:
  • A "good" value is found
  • The maxTries value is reached
  • All attempts are exhausted.
Only then the LDAP connection is disconnected.

Currently no LDAP Fail Over#

If this is a real need, let us know and we will look into adding that functionality.

LDAPS #

Yes we do LDAPS but have not added StartTLS. If this is a real need, let us know and we will look into adding that functionality.

Usage #

Command-Line Arguments
  • UniqueValue - No arguments will use all values from the uniquevaluefinder.properties file.
  • UniqueValue - CN A - Two arguments will overwrite the attributeForUniqueValue and preFix values in the uniquevaluefinder.properties file.
  • UniqueValue - CN A "" 100000 6 true - Six arguments will overwrite the attributeForUniqueValue, preFix, startValue, maxTries, maxLength, and counterPad values in the uniquevaluefinder.properties file.
  • UniqueValue - CN A "A10" 100000 6 true true - Seven arguments will overwrite all the "normal" values in the uniquevaluefinder.properties file.

WARNING TLS or SSL no keystore#

When you use SSL or TLS connections done with this Tool, we will assume the SSL or TLS cert presented by the server is valid. No certificate Validation of the certificate presented by the LDAP server will be performed. We use our Fake Trust Manager

Error Results#

You should only get a proper value or one of the following Error Results:
  • NO_CONNECTION - The program could not connect to the LDAP server
  • INVALID_DATA - This occurs when you specify parameters combinations that are not supported
  • NO_UNIQUE_NAME - No unique values were found within the constraints of the parameters provided.
  • MAX_TRIES_REACHED - No unique values were found before the maxTries limit was reached.

Unique Value Finder Download(info)#

Unique Value Finder Download(info)

Note: the .Z extension is a simple ZIP file.

Unique Value Finder with Driver#

An example of how it is used with a DirXML driver

Unique Value Finder with User Application#

Question, Comments, Suggestions?#

Let us know.

More Information#

There might be more information for this subject on one of the following:

Add new attachment

Only authorized users are allowed to upload new attachments.

List of attachments

Kind Attachment Name Size Version Date Modified Author Change note
z
uniquevalues.Z 1,404.0 kB 1 24-May-2011 12:41 jim Beta - use at own risk.
« This page (revision-57) was last changed on 24-Aug-2014 20:03 by jim