Generate unique samaccountname for AD source

Hi,
We need to generate unique samaccountname using rule for AD source. For uniqueness I want to use the below sample code for identity now but not getting how to modify it for identitynow instead of identityiq.

public boolean isUnique ( String username ) throws GeneralException {
QueryOptions ops = new QueryOptions();
ops.addFilter( Filter.ignoreCase( Filter.eq( “uid”, username ) ) );
ops.addFilter( Filter.eq( “application”, application ) );
int numberFound = context.countObjects( Link.class, ops );
return numberFound == 0;
}

Here the application filter needs to replaced with source filter. Kindly let me know how to do this.

Regards,
Mahesh

Hi,
IdentityNow has built-in mechanisms in the transforms or via the UI using a generator, to create unique account names. See IdentityNow Transforms - Username Generator - Compass

Your code example assumes that accounts are never deleted. If that is true, it should be OK, but otherwise you could run into issues. Let’s say you have “user”, “user1”, “user2”, “user3”. User 1 leaves the organization and their account gets removed leaving “user”, “user2”, “user3”. When a new user comes, with the same base user name, the code would once again generate the account name “user3”.

  • Menno