logo

The ConnectWise Control forum has moved to ConnectWise University! This forum has been locked and is in read-only mode. Click here for instructions on how to access the new forum.

Welcome Guest! You can not login or register.

Notification

Icon
Error

Options
Go to last post Go to first unread
alphaz18  
#1 Posted : Saturday, September 3, 2016 3:16:30 PM(UTC)
alphaz18


Rank: Newbie

Joined: 8/7/2013(UTC)
Posts: 4
Location: Canada

Hi, I was reading through the documentation, but I couldn't figure out a way to
get the logged in users permissions or Security Role.
is there a way I can get the name of the security role or the security permissions in a js script?

Thanks!

Alexander  
#2 Posted : Tuesday, September 6, 2016 11:39:12 PM(UTC)
Alexander


Rank: Administration

Medals: Level 3: Shirt off your back! Received 25 Thanks!

Joined: 7/23/2013(UTC)
Posts: 715
Man
Location: Raleigh, NC

Was thanked: 66 time(s) in 63 post(s)
From your Service.ashx, you can call Permissions.GetEntriesForUser(), which returns an IEnumerable<PermissionEntry>; an IEnumerable is converted to an array when passed to javascript, and a PermissionEntry is just a name and allow/deny.

If you just want the roles, you can use this (which is pretty much what GetEntriesForUser uses internally, just without the additional step of getting the PermisionEntries): HttpContext.Current.User.As<IWebPrincipal>().SafeNav(_ => _.GetRoles()).SafeEnumerate()
That returns an IEnumerable<string>.
ScreenConnect Team
alphaz18  
#3 Posted : Thursday, September 8, 2016 5:17:09 PM(UTC)
alphaz18


Rank: Newbie

Joined: 8/7/2013(UTC)
Posts: 4
Location: Canada

Thanks a lot for that,
where can I find the definition of PermissionEntry?
I tried PermissionEntry.Name and that worked. but no idea what the value parameter is..

Thanks
Alexander  
#4 Posted : Friday, September 9, 2016 6:18:31 PM(UTC)
Alexander


Rank: Administration

Medals: Level 3: Shirt off your back! Received 25 Thanks!

Joined: 7/23/2013(UTC)
Posts: 715
Man
Location: Raleigh, NC

Was thanked: 66 time(s) in 63 post(s)
Oh, it's PermissionEntry.AccessControlType. I don't think we have it in our documentation at the moment, but if you make a method with just, say, "return Permissions.GetEntriesForUser();" and invoke it from your browser, you can see the result as JSON, including the objects' fields.
(Incidentally, trying that out myself reminded me that some of the permission entries are SessionPermissionEntries or SessionOwnershipPermissionEntries rather than plain PermissionEntries, so they've got additional fields to indicate session groups or owned/unowned.)
ScreenConnect Team
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.