Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

.net Code to check the document library rights

  Asked By: Darren    Date: Mar 28    Category: Sharepoint    Views: 1838

Anybody have idea how to check the users and permission for individual
document library level by programmaticaly ?

which object model should be use or anybody having idea how to do this.

I want this for auditing purpose.



7 Answers Found

Answer #1    Answered By: Amrita Durgude     Answered On: Mar 28

If you are planning to check  if user have permissions on document  library

Have you tried DoesUserHavePermissions() function?

If you want to get all permissions for the document library  I can suggest using
webservice you can get metadata

for each document in the library.

Answer #2    Answered By: Maricela Conway     Answered On: Mar 28

I want to check  the available users  and it's permission  for specific the
document library.
and then write it to excel file. is any code  or object  mode is use for it?
which web service is use to check document  library metadata.

Answer #3    Answered By: Vinay Thakur     Answered On: Mar 28

Here is a code  sample I have found from google.

XmlNode GetPermissions(string URL, string ListName)
URL += "/_vti_bin/Permissions.asmx";
Permissions oPermissionsService = new Permissions();
oPermissionsService.Url = URL;
oPermissionsService.Credentials =
XmlNode oNode = oPermissionsService.GetPermissionCollection(ListName, "List");
return oNode;

where URL is the url of the sharepoint site that has the document  library.

The address of the actual code is


You would need to parse the xmlnode for the results.
You can check


for the xml result.

If I am not mistaken you can also use dws.asmx for the metadata.

Answer #4    Answered By: Shameka Rich     Answered On: Mar 28

I guess this is what you are looking for, if you will run the code  on the
SharePoint machine:


All these classes/objects have a property called RoleAssignments and it returns
a SPRoleAssignmentCollection.
Loop the SPRoleAssignmentCollection and you get a SPRoleAssignment object. The
SPRoleAssignment object  have a property RoleDefinitionBindings which is a
SPRoleDefinitionBindingCollection object. Loop this and you get a
SPRoleDefinition object. You can even check  the BasePermissions property for the
SPRoleDefinition and get the permissions. BasePermissions is a SPBasePermissions
object and you use bitwise operators to check what permissons it has.

The SPRoleAssignment is the user or group that is assigned a role
(SPRoleAssignment.Member.Name will give you the name). The Member property is a
SPPrincipal object and if you cast it to a SPUser object or SPGroup object you
get more info.
The SPRoleDefinition is the role the user/group is given (Ful Control,
Contribute, Read, etc)
The SPBasePermissions is what the role can do, Edit ListItem, Add ListItem etc.

So look for the following in the SDK and you will get some samples:

Hope this is what you are looking for

If this is not anough I can maybe send you some samples.

Answer #5    Answered By: Latisha Schneider     Answered On: Mar 28

can you pls provide sample code  for this and is this applicable to the WSS
2.0 object  model.

Answer #6    Answered By: Nora Maxwell     Answered On: Mar 28

The objects Hans supplied are strictly for the Windows SharePoint Services 3.0
object model  and with not work in Windows SharePoint Services 2.0.

Answer #7    Answered By: Corina Duran     Answered On: Mar 28

I dont know how to do it in WSS 2.0. Check the WSS 2.0 SDK.

Didn't find what you were looking for? Find more on .net Code to check the document library rights Or get search suggestion and latest updates.