Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Adding Users To A SharePoint 2013 Group Using CSOM
WhatsApp
Gowtham Rajamanickam
8y
28.9
k
0
1
25
Blog
Steps
Open Visual Studio in your system
Select console application template and give the name as anything you like.
Add a Microsoft.Client Assembly reference file in right side reference tab in Visual Studio.
Replace Program.cs with the source code given below.
Code snippet
using
System;
using
Microsoft.SharePoint.Client;
namespace
GowthamArticles
{
class
Addusertogroup
{
static
void
Main()
{
ClientContext clientContext =
new
ClientContext(
"https://gowtham.sharepoint.com/tutorials"
);
GroupCollection collGroup = clientContext.Web.SiteGroups;
Group oGroup = collGroup.GetById(7);
UserCreationInformation userCreationInfo =
new
UserCreationInformation();
userCreationInfo.Email =
"
[email protected]
"
;
userCreationInfo.LoginName = @
"sp\dev"
;
userCreationInfo.Title =
"gowtham"
;
User oUser = oGroup.Users.Add(userCreationInfo);
clientContext.ExecuteQuery();
}
}
}
Thanks for reading my blog.
SharePoint
CSOM
Up Next
How to Add Choices to Existing Choice Field Using CSOM in SharePoint 2013 Online
Ebook Download
View all
Getting Started with SharePoint Framework Development using TypeScript, PnP JS, and React JS
Read by 4.9k people
Download Now!
Learn
View all
Membership not found