[Building Sakai] way to tell if current user has admin privileges?
Noah Botimer
botimer at umich.edu
Wed Mar 31 10:56:56 PDT 2010
Ahh. I resisted the urge to give the technical answer, because I'm usually positively wrong. Negatively wrong this time -- oh well.
SecurityService.isSuperUser() checks the current user.
Inject or use the ComponentManager. It's in the authz package (in kernel-api). Don't use the cover or the unit test police will get you. :-)
You can also pass a user ID if you need to check someone specific (but scrutinize the technique if you think you need to do this -- only really privileged, magical super-admin maintenance code should ever need to do it).
Thanks,
-Noah
On Mar 31, 2010, at 1:49 PM, Nicola Monat-Jacobs wrote:
> Ah, I think I should have been more specific. I'm working on a custom sakai tool, and I'm wondering if there is a java method to determine this? Many tools treat users enrolled in the admin workspace as though they were admin, so I imagine there must be some way to test for it.
>
> Thanks,
> Nicola
>
> On Mar 31, 2010, at 10:43 AM, Noah Botimer wrote:
>
>> Yes. Being in Admin Workspace is the magic and sole deciding factor. There should only be one role, so there shouldn't be any confusion there.
>>
>> A way to check as the user would be to try to visit /portal/site/!admin. I'm sure we could come up with something programmatic/scriptable if you needed.
>>
>> Thanks,
>> -Noah
>>
>> On Mar 31, 2010, at 1:36 PM, Nicola Monat-Jacobs wrote:
>>
>>> I may be forgetting something obvious, but is there any easy way or method to tell if the current user has admin privileges? Not the 'admin' user, but a regular user who is enrolled in the Admin Workspace?
>>>
>>> Thanks,
>>> Nicola
>>> _______________________________________________
>>> sakai-dev mailing list
>>> sakai-dev at collab.sakaiproject.org
>>> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>>>
>>> TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of "unsubscribe"
>>>
>>>
>>
>
>
>
More information about the sakai-dev
mailing list