Orchestration Active Directory - Create and update AD Object

justx
Mega Expert

Hello community,

I've managed to create the AD user through Workflow (Orchestration) - Create AD Object, need help - I have some questions

Vivek helped me in the old thread.

Now I want to ask if anybody there could help me with the following:

When the user is created by the workflow I do not know how to make the workflow create AD User Email and Logon name

find_real_file.png

The above is created by the workflow.

And here everything is empty

find_real_file.png

When I create the user without the workflow, manually:

find_real_file.png

find_real_file.png

I want the workflow to create the logon name @company.com and create DOMAINname\username.
Also to populate First Name + Display name.

find_real_file.png

The above is my Create AD object.


Another thing which I want to know, is there any list with all workflow.inputs ?
How can I check what is inside u_user table ?
I understood about u_user.first_name and .last_name is taking from the table u_user the names, but how can I see if there is an option for Email ?


The missing attributes in the LDAP Viewer software I can see that the user manually created in the AD is having userPrincipalName , givenName, sn + displayName
But the created by the workflow is not having those attributes in the LDAP.

Any help will be highly appreciated.


Regards,
Niki

1 ACCEPTED SOLUTION

Hi Niki,



I believe the update AD activity looks for Samaccountname field in the AD. Samaccountname is a unique field in the AD. So before using update AD activity, add the Samaccountname field to Create AD activity itself.



"sAMAccountName":"${workflow.inputs.u_user.user_name}"



Once your account has samaccountname you won't get this error like missing



Regards,


Vivek


View solution in original post

19 REPLIES 19

Hi Niki,



I believe the update AD activity looks for Samaccountname field in the AD. Samaccountname is a unique field in the AD. So before using update AD activity, add the Samaccountname field to Create AD activity itself.



"sAMAccountName":"${workflow.inputs.u_user.user_name}"



Once your account has samaccountname you won't get this error like missing



Regards,


Vivek


Hello again, Vivek,



Thank you very much. That was the thing I was missing in the whole situation.
You are awesome!



And one more additional question, is there any way to extend the limitations of characters in Object data, it is giving me only 254.



{"givenName" : "${workflow.inputs.u_user.first_name}", "sn" : "${workflow.inputs.u_user.last_name}", "userPrincipalName" : "${workflow.inputs.u_user.email}", "sAMAccountName":"${workflow.inputs.u_user.user_name}", "displayName" : "${workflow.inputs.u_user.user_name}"}



Trying to add the above, but it is 258 without spaces, 268 with spaces.



Thanks in advance,
Niki


And how can I configure the workflow to be triggered automatically every time a new user is added in SNOW ?
Do I need to use Workflow schedule or there are other options ?



How exactly is working the workflow schedule, did he checked every user to understand if there is a new added user (or changes on the already created) ?



When I use Workflow Schedule with the option On Demand, do I need to run it manually ?



Thanks,
Niki


Hi Niki,



You can write a business rule on user table whenever a record inserts or update. The script would be like below. Modify your script with your workflow name and your workflow variables.



var wfgr = new GlideRecord('wf_workflow');


wfgr.addQuery('name','Worflow Name');


wfgr.query();


if(wfgr.next())


{


var wfId = wfgr.sys_id;



var wf = new Workflow();


var vars = {};


vars.u_user.user_name= current.user_name; //Pass your variables here


vars.u_user.first_name = current.first_name;


//More variables


var context = wf.startFlow(wfId,current,'insert',vars);


}



Regards,


Vivek


Hello Vivek,



Thanks for your suggestion, actually I found an script for executing the business rule and want your opinion:



(function executeRule(current, previous /*null when async*/) {



      startWorkflow(current.cat_item.workflow.toString());  


         


      function startWorkflow(id) {  


            var w = new Workflow();  


            var context = w.startFlow(id, current, current.operation(), getVars());  


            if (context != null)  


            current.context = context.sys_id;  


      }  



      function getVars() {  


            var vars = {};  


            for (var n in current.variables)


                  vars[n] = current.variables[n];  


             


            return vars;  


      }  



})(current, previous);



What do you think ?
What do I need to change in order to trigger the workflow. I've set it:


find_real_file.png



What I need to trigger the first workflow activity:


find_real_file.png




When I make update on User I do not see anything in the system log.



Additionally when I use other script -> the following:


(function executeRule(current, previous) {



var wflw = new Workflow();



wflw.startFlow(wflw.getWorkflowFromName('Name of Workflow'), current, 'update');



})(current, previous);




I got the following error:


find_real_file.png




Which I think its because when the script is pushing to trigger the workflow, the workflow itself doesn't know which user its updated/created.



Regards,
Niki