Hi,

I need to create unique login names and would like to display the suggested cn on the actual form where we create users.
I used to do a dn query against existing users but that only wokes for existing users and we want to have a list of both current and used login names.
So I created a list of all login names as an object with all used cn:s as multi valued description.
My thought was that it is easy to maintain in a loop back driver and also easy to read. Maybe there is a better solution.

Now to the question.

On the form I have a field where I calculate the cn with this code:
try {
var fn=form.getValue('firstname');
var ln=form.getValue('lastname');
var varcnlist=IDVault.get(null, "cn=usedNames,ou=users,o=data","list", "Description");
var dn,cn,dna

cn=(fn.substring(0,1)+ln.substring(0,3)).toLowerCa se();
form.setValues('loginname',cn);
dn='cn='+cn+',ou=personal,ou=users,o=data';

try{
var v1 = IDVault.get(null,dn,"user","FirstName");
} catch (e) {alert (e);}
if (v1) {

for (var i=1;9;i++) {
cn=(fn.substring(0,1)+ln.substring(0,3)+i).toLower Case();
form.setValues('loginname',cn);
dn='cn='+cn+',ou=personal,ou=users,o=data';

try{
var v1 = IDVault.get(null,dn,"user","FirstName");
} catch (e) {alert (e); break}
if (v1) {
} else {
//invocation.proceed();
break;
}
}
}
} catch (e) {alert (e);}
Where I just added the line "var varcnlist=IDVault.get(null, "cn=usedNames,ou=users,o=data","list", "Description");" to get an array of the used names.

How do I compare the suggested "cn" to the array "varcnlist" ? Do I need to use "for each" or is there a quicker way?