Question
· Apr 3, 2020

Calling Security.Users class in a script

Hi,

Has anyone tried to call Security.Users class (in %SYS namespace) for creating or editing users from a shell script (or any programming language)?

If yes, can you please share your code?

 

We are trying to automate some stuff and would like to know how this worked for others.

 

Thanks,

Bharath Nunepalli.

Discussion (7)3
Log in or sign up to continue

Hi Bharath,

I don't really have any sample code for you but I'm not sure I (or other readers) have a good idea of what exactly you are trying to do. Have you already reviewed the class reference? I think the Create(), Get(), and Modify() documentation together describe quite well how you could use Security.Users.

https://cedocs.intersystems.com/csp/documatic/%25CSP.Documatic.cls?PAGE=CLASS&LIBRARY=%25SYS&CLASSNAME=Security.Users

You can call methods from command line even like you call routines. Imagine you have a class Test in package TestClasses and a method printData which prints the data to your output device. Then you can call csession instance -"U" namespace "##class(Test).printData("""data""")".

Of course the methods must be ClassMethods. You must test the number of " - signs.  In PowerShell for instance I needed around 14(! sic) "-signs to send a valid command to Caché.

Here the example:

csession ${INSTANCE} -"U" ${NAMESPACE}  "##class(TestClasses.Test).printData(""""""""""""""hello"""""""""""""")"

hello