cancel
Showing results for 
Search instead for 
Did you mean: 

Remove Document Create Privileges from User Group

Not applicable

Hi Guys,

Is it possible to remove Document Create privileges from some User Group? It's some reasons I do need to avoid them to create/upload document and allow them later using Unity Script.

I would be grad if you could show me a sample code also [emoticon:c4563cd7d5574777a71c318021cbbcc8]

Thank you.

KOBPONG

1 ACCEPTED ANSWER

Ariel_Koiman
Star Contributor
Star Contributor

Hi Kobpong,

While you can't programmatically add or remove permissions from a group, I believe you can still accomplish what you're setting out to do.

Let's say all users you want to modify belong to the group "General Users". This group should never have the Document Create privilege on it. Create a separate user group called "Document Creation". From your script, you can iterate through all your users with unityApp.Core.UserAdministration.GetUsers(), and filter out the ones that belong to group "General Users". For instance, by unityApp.Core.UserAdministration.GetUsers().Where(user => user.GetUserGroups().Contains(generalUsersGroup)). Then, for each resulting user, you may call unityApp.Core.AddUserToGroups(userAtCurrentIndex, groupCollection). When you want to programmatically remove this privilege, simply apply the same logic with unityApp.Core.RemoveUserFromGroups(). Functionally speaking, this should have the same effect of applying and removing the Create privilege programmatically.

Good luck!

Best,

Ariel Koiman
Developer II, Capture

View answer in original post

3 REPLIES 3

Ariel_Koiman
Star Contributor
Star Contributor

Hi Kobpong,

While you can't programmatically add or remove permissions from a group, I believe you can still accomplish what you're setting out to do.

Let's say all users you want to modify belong to the group "General Users". This group should never have the Document Create privilege on it. Create a separate user group called "Document Creation". From your script, you can iterate through all your users with unityApp.Core.UserAdministration.GetUsers(), and filter out the ones that belong to group "General Users". For instance, by unityApp.Core.UserAdministration.GetUsers().Where(user => user.GetUserGroups().Contains(generalUsersGroup)). Then, for each resulting user, you may call unityApp.Core.AddUserToGroups(userAtCurrentIndex, groupCollection). When you want to programmatically remove this privilege, simply apply the same logic with unityApp.Core.RemoveUserFromGroups(). Functionally speaking, this should have the same effect of applying and removing the Create privilege programmatically.

Good luck!

Best,

Ariel Koiman
Developer II, Capture

Apologies--it seems a fragment of the code got cut off. It should read: unityApp.Core.UserAdministration.GetUsers().Where(user => user.GetUserGroups().Contains(generalUsersGroup)), where generalUsersGroup is the UserGroup object.

Got it, thanks Ariel