Presentation is loading. Please wait.

Presentation is loading. Please wait.

Microsoft ® Official Course Managing and Accessing User Profile Data Microsoft SharePoint 2013 SharePoint Practice.

Similar presentations


Presentation on theme: "Microsoft ® Official Course Managing and Accessing User Profile Data Microsoft SharePoint 2013 SharePoint Practice."— Presentation transcript:

1 Microsoft ® Official Course Managing and Accessing User Profile Data Microsoft SharePoint 2013 SharePoint Practice

2 Module Overview Overview of User Profile Data in SharePoint 2013 Understanding Options for Accessing User Profile Data Managing User Profile Data Managing User Profile Properties

3 Lesson 1: Overview of User Profile Data in SharePoint 2013 Introducing User Profiles Property Data Sources Profile Properties and Data Protection Demonstration: Reviewing the Default User Profile Properties SharePoint Configuration Requirements and Considerations

4 Introducing User Profiles User Profiles Profile properties Data sources Profile subtypes

5 Property Data Sources Directory Services (for example Active Directory) User (stored in SharePoint) Business Connectivity Services (BCS)

6 Profile Properties and Data Protection Confidential data exposed by SharePoint Directory services Line-of-business applications Profile properties have default privacy setting Public Private User can override privacy setting Administrator can control this by configuring a policy

7 Demonstration: Reviewing the Default User Profile Properties In this demonstration, you will see an overview of the default user profile properties, data type and default privacy settings. You will also review the Active Directory connection configuration settings.

8 SharePoint Configuration Requirements and Considerations User Profile Service Application User Profile Service User Profile Synchronization Service

9 Lesson 2: Understanding Options for Accessing User Profile Data Development Options for Managing User Profile Data Enumerating Users Searching for Users

10 Development Options for Managing User Profile Data Read/Write Server-side object model Read only.NET client-side object model REST JavaScript object model Exceptions Profile picture can be changed from client-side code PeopleManager.setMyProfilePicture

11 Enumerating Users Site users All users with profiles Consider Search var users = SPContext.Current.Site.RootWeb.AllUsers; foreach (var user in users) { } var context = SPServiceContext.Current; var userProfileManager = new UserProfileManager(context); var users = userProfileManager.GetEnumerator(); while (users.MoveNext()) { }

12 Searching for Users Use Keyword Query Language Specify the Local People Results result source ID: b09a7990-05ea-4af9-81ef-edfab16c4e31 var query = new Microsoft.SharePoint.Client.Search.Query.KeywordQuery (clientContext); query.set_queryText("FirstName:" + firstName); query.set_sourceId ("B09A7990-05EA-4AF9-81EF-EDFAB16C4E31"); clientContext.executeQueryAsync(function () { … });

13 Lesson 3: Managing User Profile Data Creating User Profiles Retrieving User Profile Properties by Using Client- side Code Retrieving User Profile Properties by Using Server- side Code Updating User Profile Properties Discussion: Accessing User Profile Data with Client-side Code

14 Creating User Profiles Reference assemblies: Microsoft.Office.Server Microsoft.Office.Server.UserProfiles Include Microsoft.Office.Server.UserProfiles namespace SPServiceContext serviceContext = SPServiceContext.Current; UserProfileManager = new UserProfileManager(serviceContext); UserProfile userProfile = userProfileManager.CreateUserProfile("CONTOSO\Mike");

15 Retrieving User Profile Properties by Using Client-side Code var properties = ["AccountName“, “FirstName“]; var username = "CONTOSO\Mike"; var peopleManager = new SP.UserProfiles.PeopleManager(clientContext); var profilePropertiesRequest = new SP.UserProfiles.UserProfileProeprtiesForUser (clientContext, username, properties); var profileProperties = peopleManager.getUserProfilePropertiesFor (profilePropertiesRequest); clientContext.load(profilePropertiesRequest); clientContext.executeQueryAsync(function () { accountName = profileProperties[1]; // Process success. }, function() { // Process failure. });

16 Retrieving User Profile Properties by Using Server-side Code UserProfile user = … ; // Assume a valid UserProfile instance. // Properties for common profile properties. var accountName = user.AccountName; // Indexer for any properties. var accountName = user["AccountName"].Value; // PropertyConstants enumeration to simplify development. var accountName = user[PropertyConstants.AccountName].Value; // Enumerator or index for multi-value profile properties. var values = user[PropertyConstants.AccountName].GetEnumerator(); var value1 = user[PropertyConstants.AccountName][0];

17 Updating User Profile Properties Update any property in server-side code Cannot update a property on a GET request Override by using the SPWeb.AllowUnsafeUpdates property Update the profile picture in client-side code PeopleManager.setMyProfilePicture UserProfile user = … ; // Assume a valid UserProfile instance. // Common profile properties. userProfile.DisplayName = "Display Name"; // Any profile property. userProfile["FirstName"].Value = "First Name" // Persist changes. useProfile.Commit();

18 Discussion: Accessing User Profile Data with Client-side Code In what scenarios might you use client-side code to access user profile properties?

19 Lab A: Accessing User Profile Data Exercise 1: Add People Search Functionality to an App Exercise 2: Display User Properties in the App

20 Lab Scenario The human resources team needs to view user profiles for company employees. They must be able to locate an employee profile quickly by searching for the employee. They must be able to search for users by account name, name, or by specifying the user's department. Your task is to add functionality to an app to provide the search functionality by using client-side code.

21 Lesson 4: Managing User Profile Properties Managing User Profile Subtypes Adding User Profile Properties Updating User Profile Properties Deleting User Profile Properties

22 Managing User Profile Subtypes ProfileSubtypeManager subTypeManager = ProfileSubtypeManager.Get(SPServiceContext.Current); ProfileSubtype newSubtype = subtypeManager.CreateSubtype ("Name", "Display name", ProfileType.User); subtypeManager.DeleteSubtype("Name"); ProfileSubType subtype = subtypeManager.GetProfileSubtype("Name"); List profiles = (List )subtypeManager. GetSubtypesForProfileType(ProfileType.User);

23 Adding User Profile Properties ProfilePropertyManager class Core Property CorePropertyManager.Create method CoreProperty class Type Property ProfileTypePropertyManager.Create method Specify ProfileType.User and core property ProfileTypeProperty class Subtype Property ProfileSubtypePropertyManager.Create method Specify subtype name and type property ProfileSubtypeProperty class

24 Updating User Profile Properties SPServiceContext context = SPServiceContext.Current; // Obtain a reference to the UserProfileManager instance. UserProfileManager uPM = new UserProfileManager(context); // Obtain a reference to the ProfileSubtypePropertyManager instance that represents the default profile subtype. ProfileSubtypePropertyManager defaultPSPM = upm.DefaultProfileSubtypeProperties; // Obtain a reference to the property. ProfileSubtypeProperty property = defaultPSPM.GetPropertyByName(propertyName); // Update the property. // Call the Commit method to persist the changes to the property property.Commit();

25 Deleting User Profile Properties ProfilePropertyManager propManager = …; ProfileSubtypePropertyManager subtypePropManager =…; subtypePropManager.RemovePropertyByName("Name"); propManager.Reset(); ProfileTypePropertyManager typePropManager = …; typePropManager.RemovePropertyByName("Name"); CorePropertyManager corePropManager = …; corePropManager.RemovePropertyByName("Name");

26 Lab B: Managing User Profile Properties Exercise 1: Add Code to Display User Profile Properties Exercise 2: Add Code to Manage User Profile Properties

27 Lab Scenario The human resources team needs to add and remove user profile properties in response to business needs, for example to enable them to track compliance with regulations, and to track security clearance for specific projects. As regulations change, or projects finish they will remove the profile property to avoid a proliferation of properties. In addition to the ability to add and remove properties they need to be able to control visibility of the properties. Your task is to add code to a web part to display, update, add, and delete user profile properties.

28 Module Review and Takeaways

29


Download ppt "Microsoft ® Official Course Managing and Accessing User Profile Data Microsoft SharePoint 2013 SharePoint Practice."

Similar presentations


Ads by Google