· Mar 30, 2021

Get user properties outside of %SYS namespace

I have a CSP page that is supposed to show some user info (Full name and some other properties retrieved from AD)

I am unable to get them outside of %SYS namespace using Security.Users class. Is there another mechanism to do that, or I am using Security.Users class incorrectly?

Product version: Caché 2018.1
Discussion (22)1
Log in or sign up to continue

Class Security.Users is available only from %SYS, you can map it to your namespace, but I would not recommend to do it. I think, you can just have a method just for this exact thing, where you can switch to %SYS namespace, gather what's you need, and that's it. In this method you will need to use New $namespace command, so, when it will return back to your original namespace when returns. As a ClassMethod it would look like this

ClassMethod GetUserInfo(username, ByRef props) As %Status
  New $Namespace
  Set $Namespace = "%SYS"
  Return ##class(Security.Users).Get(username, .props)

The %SYS namespace sources are open to study and often (but not always) serve as a coding etalon reference for application developers. This is a whole storehouse of knowledge for those who want to better understand certain mechanisms work of system classes.
If some of the commands found there are not documented, but effectively do useful work, then why can't they be used by application developers?
In addition, I do not rule out the fact that some of them are simply forgot to document.

What really needs to be hidden or potentially dangerous is already hidden in the deployed classes.

If you look at a modern version of Caché or IRIS you'll find that ^%SYS.SECURITY is hidden. I would be curious how long ago you found out about the method you are suggesting, as it has been hidden since at least 2016.

Full disclosure, I work at InterSystems, but I try not to say anything on the community that goes beyond the bounds of what a non-InterSystems community member would be able to say. If you want the official InterSystems word, I would recommend you reach out to the WRC / your account rep, but I can almost guarantee they'll echo Steve's and my response.

Just to give my 5 cents on this: it's not great to suggest unsupported approaches to solve problems.

But for us it is always great feedback what features we could include the support for in the product. 

@Vitaliy.Serdtsev , thank you for your continuous willingness to help developers to solve their issues.

@Vic Sun your point is very fair - it's almost impossible to support unsupported usage and it can cause unpredictable problems. 

Thank you all!