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
PnP Core Component - Get Site Collection Administrators in SharePoint 2016
WhatsApp
Vijai Anand Ramalingam
8y
3.4
k
0
0
25
Blog
Please refer
to the
Introduction to PnP Core Component
and
OfficeDevPnP.Core
for more details. I have created a console application and added
SharePointPnPCore2016
NuGet package for the SharePoint 2016 version.
Code Snippet:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
using
Microsoft.SharePoint.Client;
using
OfficeDevPnP.Core;
namespace
SP2016PnPCoreComponentDemo
{
class
Program
{
static
void
Main(
string
[] args)
{
// Input Parameters
string
siteUrl =
"http://c7395723754/"
;
string
userName =
"administrator"
;
string
password =
"Mf165Nz2WV"
;
string
domain =
"AD2012"
;
OfficeDevPnP.Core.AuthenticationManager authMgr =
new
OfficeDevPnP.Core.AuthenticationManager();
try
{
// Get the client context
using
(var ctx = authMgr.GetNetworkCredentialAuthenticatedContext(siteUrl, userName, password, domain))
{
// Get Administrators
List<OfficeDevPnP.Core.Entities.UserEntity> adminColl = ctx.Web.GetAdministrators();
foreach
(OfficeDevPnP.Core.Entities.UserEntity admin
in
adminColl)
{
Console.WriteLine(
"Title: "
+ admin.Title +
" ---- LoginName: "
+ admin.LoginName +
" ---- Email: "
+ admin.Email);
}
}
}
catch
(Exception ex)
{
Console.WriteLine(
"Error Message: "
+ ex.Message);
}
}
}
}
SharePoint 2016 CSOM Extension PnP Core Component.
Up Next
How To Get All Site Collection Administrators From SharePoint Online Site Collections Using PnP PowerShell
Ebook Download
View all
SharePoint Framework (SPFx) A Developers Guide
Read by 11.1k people
Download Now!
Learn
View all
Membership not found