Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get user permissions?

I want to retrieve all permission for user as list of premission id's but:

user.get_all_permissions() 

give me list of permission names. How to do it?

like image 592
Nips Avatar asked May 15 '13 19:05

Nips


People also ask

How do I list a user's permissions in Active Directory?

Open “Active Directory Users and Computers”. Go to any Organizational Units whose permissions want to see. Right-click to open “Properties” window, select the “Security” tab. Click “Advanced” to see all the permissions in detail.

How do I give permission to user?

chmod o-rwx foldername To change directory permissions for everyone, use “u” for users, “g” for group, “o” for others, and “ugo” or “a” (for all). chmod ugo+rwx foldername to give read, write, and execute to everyone. chmod a=r foldername to give only read permission for everyone.


Video Answer


1 Answers

to get all the permissions of a given user, also the permissions associated with a group this user is part of:

from django.contrib.auth.models import Permission  def get_user_permissions(user):     if user.is_superuser:         return Permission.objects.all()     return user.user_permissions.all() | Permission.objects.filter(group__user=user) 
like image 127
DRC Avatar answered Oct 02 '22 16:10

DRC