Skip to content

Commit

Permalink
Moved documentation to MD format
Browse files Browse the repository at this point in the history
  • Loading branch information
jansenbe committed Aug 19, 2014
1 parent 053adc3 commit 6b8283a
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 22 deletions.
5 changes: 2 additions & 3 deletions Scenarios/Core.GroupManagement/Core.GroupManagement.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30501.0
VisualStudioVersion = 12.0.30723.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core.GroupManagement", "Core.GroupManagement\Core.GroupManagement.csproj", "{14DAFA3D-E6C7-4A05-88CA-E1624B584E17}"
EndProject
Expand All @@ -10,8 +10,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{EEB25F74-5
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Documentation", "Documentation", "{889966F0-3CAD-4D20-8AAB-831831A02B3F}"
ProjectSection(SolutionItems) = preProject
Manage groups and users.docx = Manage groups and users.docx
readme.txt = readme.txt
readme.md = readme.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OfficeDevPnP.Core", "..\..\OfficeDevPnP.Core\OfficeDevPnP.Core\OfficeDevPnP.Core.csproj", "{F2077977-8EBF-409D-BBF4-8EFB328928A8}"
Expand Down
Binary file not shown.
99 changes: 99 additions & 0 deletions Scenarios/Core.GroupManagement/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Manage users and groups #

### Summary ###
This scenario shows how you can manage groups and users inside a site collection.

### Applies to ###
- Office 365 Multi Tenant (MT)
- Office 365 Dedicated (D)
- SharePoint 2013 on-premises

### Prerequisites ###
None

### Solution ###
Solution | Author(s)
---------|----------
Core.GroupManagement | Bert Jansen (**Microsoft**)

### Version history ###
Version | Date | Comments
---------| -----| --------
1.0 | July 11th 2014 | Initial release

### Disclaimer ###
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**


----------

# General comments #
This shows how you can work with groups and users by adding/removing them to the site collection. Adding users and groups in one thing, next thing is giving them a permission level so that they’ve access to SharePoint and that’s also shown in this sample. The actual implementation of these group/user/permission level actions is implemented in OfficeDevPnP Core as extension methods. This results in a very easy to use model which is shown via below code snippets.

## ADDING GROUPS AND ADDING USERS TO GROUPS ##
```C#
cc.Load(cc.Web, web => web.CurrentUser);
cc.ExecuteQuery();
Microsoft.SharePoint.Client.User currentUser = cc.Web.CurrentUser;

if (!cc.Web.GroupExists("Test"))
{
Group group = cc.Web.AddGroup("Test", "Test group", true);
cc.Web.AddUserToGroup("Test", currentUser.LoginName);
}
```

## REMOVING GROUPS ##
```C#
if (cc.Web.GroupExists("Test"))
{
cc.Web.RemoveGroup("Test");
}
```

## REMOVING USERS FROM GROUPS ##
```C#
cc.Load(cc.Web, web => web.CurrentUser);
cc.ExecuteQuery();
Microsoft.SharePoint.Client.User currentUser = cc.Web.CurrentUser;
if (cc.Web.GroupExists("Test"))
{
if (cc.Web.IsUserInGroup("Test", currentUser.LoginName))
{
cc.Web.RemoveUserFromGroup("Test", currentUser.LoginName);
}
}
```

## ADD PERMISSION LEVEL TO GROUP ##
```C#
if (cc.Web.GroupExists("Test"))
{
cc.Web.AddPermissionLevelToGroup("Test", RoleType.Contributor);
}
```

## ADD PERMISSION LEVEL TO USER ##
```C#
cc.Load(cc.Web, web => web.CurrentUser);
cc.ExecuteQuery();
Microsoft.SharePoint.Client.User currentUser = cc.Web.CurrentUser;
cc.Web.AddPermissionLevelToUser(currentUser.LoginName, RoleType.Reader);
```

## REMOVE PERMISSION LEVEL FROM GROUP ##
```C#
if (cc.Web.GroupExists("Test"))
{
cc.Web.RemovePermissionLevelFromGroup("Test", RoleType.Reader);
}
```

## REMOVE PERMISSION LEVEL FROM USER ##
```C#
cc.Load(cc.Web, web => web.CurrentUser);
cc.ExecuteQuery();
Microsoft.SharePoint.Client.User currentUser = cc.Web.CurrentUser;
cc.Web.RemovePermissionLevelFromUser(currentUser.LoginName, RoleType.Reader);
```

19 changes: 0 additions & 19 deletions Scenarios/Core.GroupManagement/readme.txt

This file was deleted.

0 comments on commit 6b8283a

Please sign in to comment.