Skip to main content

Hi, as part of an Active Directory account rename process we are developing, I need to check the availability of a username in Active Directory.

 

I can see various options in the Active Directory event listings however I can't see one that fits my criteria. The basic workflow is that Joanne Bloggs gets married and becomes Joanne Jones. What we need to do is to check the availability of the new username - our account naming convention is first letter of first name followed by surname. So for this example:

Current username - jbloggs

New username - jjones

 

If there is already an account named jjones then we need to instead use jjones1. If somebody already has the jjones1 username then we use jjones2, and so on.

 

Is this possible? Also I can't see an account rename option in the Active Directory events, is there no way of renaming or maybe copying a user account? Thanks

Hi,

 

While there isn't a method for checking is a user exists, you might do is get  creative is using the AD User --> GetUserDetails method.  Create an activity where you use that method to look up a username (the one you are targeting) and set a process datafield to the email address since that should be populated for all your accounts. You can then configure line rules to go one of two pays depending if the email field is populated or not.

 

Now this is where we get creative, The method I mentioned will throw an exception if the user isn't found. That is fine. What we are going to do is enable the exception rule on the activity and tell K2 to not do anything with the exception. We know it will happen, we fully expect it to happen, but we don't care if it does happen. All we care about is that if it does happen that email field won't be populated thus telling us that the username is available.

 

Hope this sparks some thought...

 

S.


Thanks Scott, that seems perfect but I run into a problem when I'm trying to create a string to hld the username, e.g. from Joe Bloggs I want to create jbloggs.

 

I have seen there is a Join function within Text which seems to be concatenate but it won't allow me to build the string from the object explorer. It would be fine if I was simply using text but as I need to use two fields from a Smart Object, as soon as I add the second field, the first is removed from the expression.

 

Should I create another thread for this? Haha


You will most likely need to nest a few inline fuctions to pull this off. Unfortunately I am traveling and don't have a VM up at the moment. If I remember correctly there should either be a left, right or mid function that you could use.

 

You could use these in conjunction with an expression (start with the expression) use one function to get the first letter, the & for concatenate and then another fuction to get the second half and the returned value should be the result you are aiming for jbloggs.

 

S.


Hi Scott, I managed to use the Insert method to concatenate the strings:

http://help.k2.com/onlinehelp/k2blackpearl/userguide/4.6.4/webframe.html#Text.html

 

Thanks for your help and advice with this!


Reply