Jean Paul's Blog

There are 2 types of People in the World, One who Likes SharePoint and..

    Advertisements
  • Microsoft MVP

  • MindCracker MVP

  • CodeProject MVP

  • eBook on SharePoint 2010

  • eBook on Design Patterns

  • eBook on Windows Azure

  • NLayers Framework @ CodePlex

  • MSDN Forums

  • .Net vs. Java

    Due to Public Demand
  • Advertisements

Posts Tagged ‘user’

REST API to check User Permission

Posted by Paul on October 17, 2015

In this article we can explore the REST API to check User Permission for a Group.

Scenario

You are working in a client-side script SharePoint App. You need to check whether the current user belongs to the Approvers group. The twist is that the current user is added to an AD Group and in turn the AD Group was added to SharePoint group.

Solution: Following is the REST code to get the result.

http://sharepoint/_api/web/sitegroups/getbyname(‘Approvers’)/CanCurrentUserViewMembership

Following is the result.

image

image

You can try REST code in browser address bar itself. Later you can wrap a JavaScript or AngularJS around it to attain programmatic checking.

If I enter an invalid group name, the result will be different.

http://sharepoint/_api/web/sitegroups/getbyname(‘InvalidGroup’)/CanCurrentUserViewMembership

image

We can also check Site Collection & Sub Site permission groups using the same way.

Pre-Conditions

The above code is checking does the user have View Membership permission. In order to make this work we need to configure the following group property as true.

By default this property will be true.

image
You can find more property information using References link.

image

References

https://msdn.microsoft.com/en-us/library/office/jj245943.aspx

Summary

In this article we have explored the REST API to check User Permission for a Group.

Advertisements

Posted in SharePoint, SharePoint 2013 | Tagged: , , , , | Leave a Comment »

SQL Server–Create User / Domain User using SQL

Posted by Paul on March 23, 2012

CREATE LOGIN user1WITH PASSWORD = ’MyPassword’  USE TheDbName CREATE USER user1FOR LOGIN user1;
GO
CREATE LOGIN [Domain\user1] FROM WINDOWS;
            USE TheDbName CREATE USER user1 FOR LOGIN [Domain\user1]

Posted in C# | Tagged: , | Leave a Comment »

SQL Server–Create User / Domain User using SQL

Posted by Paul on March 23, 2012

CREATE LOGIN user1WITH PASSWORD = ’MyPassword’  USE TheDbName CREATE USER user1FOR LOGIN user1;
GO
CREATE LOGIN [Domainuser1] FROM WINDOWS;
            USE TheDbName CREATE USER user1 FOR LOGIN [Domainuser1]

Posted in C# | Tagged: , | Leave a Comment »