How to get user profiles from sharepoint into asp net core app

Introduction

ASP.NET is a popular language used for developing web applications. In this article, we will discuss how to get user profiles from SharePoint into an ASP.NET Core app. SharePoint is a web-based collaborative platform that integrates with Microsoft Office. It allows organizations to , share, and manage and other .

Step 1: Connect to SharePoint

The first step is to establish a connection to SharePoint from your ASP.NET Core app. You can use the SharePoint Client Object (CSOM) to interact with SharePoint. Here is an of how to connect to SharePoint:


using Microsoft.SharePoint.Client;

string siteUrl = "https://your-sharepoint-site-url";
string username = "your-username";
string password = "your-password";

ClientContext context = new ClientContext(siteUrl);
context.Credentials = new SharePointOnlineCredentials(username, password);

Step 2: Retrieve User Profiles

Once you have established a connection to SharePoint, you can retrieve user profiles. SharePoint stores user profiles in the User Profile Application. Here is an example of how to retrieve user profiles:


PeopleManager peopleManager = new PeopleManager(context);
UserProfilePropertiesForUser userProfileProperties = new UserProfilePropertiesForUser(context, "user-login-name");
UserProfile userProfile = peopleManager.GetUserProfileProperties(userProfileProperties);
context.Load(userProfile);
context.ExecuteQuery();

string displayName = userProfile.DisplayName;
string email = userProfile.Email;
string jobTitle = userProfile.JobTitle;

Step 3: Display User Profiles in ASP.NET Core App

Now that you have retrieved the user profiles, you can display them in your ASP.NET Core app. You can use the retrieved user profile properties to populate your app's UI. Here is an example of how to display user profiles:


User Profile

Display Name: @displayName

Email: @email

Job Title: @jobTitle

Conclusion

In this article, we discussed how to get user profiles from SharePoint into an ASP.NET Core app. We covered the to connect to SharePoint, retrieve user profiles, and display them in your app. By following steps, you can integrate SharePoint user profiles into your ASP.NET Core app and enhance its .

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents