I am created the workflow for AD integration and I have mapped AD attributes through run script but account is successfully created but that is locked in AD and also getting errors below situvations
>> Create AD ---enable AD account in this case I am getting the error in enable ad activity like below
>> Create AD ---Reset Ad passowrd---enable AD account in this case I am getting the error in reset AD activity like below
generateScratchpad();
function generateScratchpad() {
//Get First, Middle, Last name fields. Make sure they are String Fields
var first = current.variables.first_name.toString();
var last = current.variables.last_name.toString();
//create userID
var ID = first+'.'+last;
//Set the scratchpad for all needed items.
workflow.scratchpad.dN = current.variables.first_name + " " + current.variables.last_name; //Display Name (first, last)
workflow.scratchpad.first = current.variables.first_name; //First Name
workflow.scratchpad.last = current.variables.last_name; // Last Name
workflow.scratchpad.phone = current.variables.business_phone; //phone
workflow.scratchpad.email = current.variables.shared_mailbox; //email Address
workflow.scratchpad.id = ID;
function generateRandomPassword(length) {
var charset = "abcdefghijnopqrstuvwxyzABCDEFGHIJNOPQRSTUVWXYZ0123456789!@#$%^&*()_-+=<>?";
var password = "";
for (var i = 0; i < length; i++) {
var randomIndex = Math.floor(Math.random() * charset.length);
password += charset[randomIndex];
}
return password;
}
// Set the password length (default is 10, but can be customized)
var passwordLength = 15; // Change this to your desired length
var generatedPassword1 = generateRandomPassword(passwordLength);
var enc = new PasswordResetUtil();
var encrString1=enc.encryptWithKMFModule( generatedPassword1);
workflow.scratchpad.password = var generatedPassword1;
var decrString =workflow.scratchpad.clearpass= enc.decryptWithKMFModule(encrString1);
//Needs to start with a {
var object = "{ ";
//set the First name in AD
object += '"givenName" : "' + workflow.scratchpad.first + '" , ';
//set the user password in AD.
object += '"userPassword" : "' +generatedPassword1+ '" , ';
//set the last name in AD
object += '"sn" : "' + workflow.scratchpad.last + '" , ';
//set the display name in AD
object += '"displayName" : "' + workflow.scratchpad.dN + '" , ';
//if Email is not Blank, set the Email in AD
//email may not be mandatory, and we dont want to send anything if the email is not filled in.
if(!current.variables.shared_mailbox.nil()){
object += '"mail" : "' + workflow.scratchpad.email + '" , ';
}
//set the login id and the domain in AD.
object += '"userPrincipalName" : "' + ID + '" , ';
if(current.variables.business_phone != ""){
object += '"telephoneNumber" : "' + workflow.scratchpad.phone + '" , ';
}
//end the object with a }
object += "}";
/****************************************************************************************/
/****************************************************************************************/
/****************************************************************************************/
//for Information purposed and possible troubleshooting, add the whole object string to the work_notes field
current.work_notes = object+"\n"+"generatepassword:"+clearString+ "\n" +"encryptedpassword:"+encrString1+ "\n"+"decryptpassword:"+decrString;
//Set the object to the scratchpad.
workflow.scratchpad.object = object;
}