Showing posts with label user profile service. Show all posts
Showing posts with label user profile service. Show all posts

Friday, June 26, 2015

SharePoint User Display issue: Display name incorrect in one site collection

Recently I got an issue in my SharePoint 2013 production environment. One of the user display name not showing properly. Instead of his name, it is showing one of the employee who left the organization. By checking the user details in AD we got the details. AD team updated two emails for one user. One is his own email and other email is one of the employee who left the company. We tracked the issue and updated the profile AD and ran User Profile Sync. Everything worked well till now.

But user still having the issue in one site, his display name not showing correctly. Instead of his name, it is showing employee who left the organization. We are seeing this issue only for one site collection. Tried different approaches like deleting user permissions in the site through UI and using PowerShell commands. Nothing worked.

After Googling the issue, we got the resolution. We are seeing that issue due caching in SharePoint site collection. When I remove and add the data in SharePoint site group, SharePoint site collection user details from all users located in <Site URL>/_layouts/people.aspx?MembershipGroupId=0

To fix the issue, we need to remove the user from all users list and read it to the list. But before that we need to check all the user permissions in the site (including all the groups and individual permissions) and need to re add all the places. 

Hope this helps.

Friday, May 8, 2015

Prevent users to create the my sites in SharePoint

In one of my SharePoint environment, we had issue with my sites. When users click on about us, it automatically creates my site for all the user. All these my sites are created as a site collections in the web application.

We have 2000 people accessing the site and every user creating new my site. So it will be 2000 site collection in one web application. SharePoint can handle that, but we not using any my site features in our environment.
For this we just need to prevent the users to create my sites. We can do that from central admin site User profile service settings as shown below.

Open SharePoint central admin site User profile Service application. Select manage user Permissions.

We can see a popup as shown below. Select Authenticated users and uncheck “Create personal sites” option as shown the image below.
Click on Ok to save the settings.

Hope this will helps.

Monday, January 6, 2014

Create custom profile property in SharePoint user profile programmatically

While working on user profile service I got the requirement to create custom property through coding for one of my client. I have found the solution to create custom property from Ahmedmandany blog. To create the property, we have to get the current service context  by passing the site object. From the service context object create new UserProfileConfigManager object. By using UserProfileConfiguaration object we can get the CoreProperties in the service as shown the code below.

SPServiceContext currentServiceContext = SPServiceContext.GetContext(SiteCollection);
//Here SiteCollection is SPSite object for current site

UserProfileConfigManager userProfileConfigManager = new UserProfileConfigManager(currentServiceContext);

CorePropertyManager usreProfileCoreProperties = userProfileConfigManager.ProfilePropertyManager.GetCoreProperties();

Create profileProperty list and with string type objects. Insert data into the list as shown below,

List<string> myCustomProperties = new List<string>();
myCustomProperties.Add("My Custom Property");

We can get the ProfilePropertyManager object from ProfileConfigManager. 

ProfilePropertyManager propertyManager = profileConfigManager.ProfilePropertyManager;

Check the property is exits or not in CoreProperties. If not exists, add property to the core properties. Add PropertyInstance, ProfileTypeProperty and ProfileSubtypePropertyManager objects, update all the properties as per the requirements.

CoreProperty coreProperty = coreProperties.Create(false);
coreProperty.Name = profileProperty.Replace(" ", string.Empty);
coreProperty.Type = PropertyDataType.String;
coreProperty.Length = 4000;
coreProperty.DisplayName = "My Custom Property";
coreProperty.Description = "My Custom Property" ;
ProfileTypePropertyManager profileTypePropertyManager = propertyManager.GetProfileTypeProperties(ProfileType.User);
ProfileTypeProperty profileTypeProperty = profileTypePropertyManager.Create(coreProperty);
profileTypeProperty.IsVisibleOnViewer =true;
profileTypeProperty.IsVisibleOnEditor = true;

ProfileSubtypeManager profileSubTypeManager = ProfileSubtypeManager.Get(currentServiceContext);
ProfileSubtype profileSubtype = profileSubTypeManager.GetProfileSubtype               (ProfileSubtypeManager.GetDefaultProfileName(ProfileType.User));
ProfileSubtypePropertyManager profileSubtypePropertyManager = profileSubtype.Properties;

ProfileSubtypeProperty profileSubtypeProperty = profileSubtypePropertyManager.Create(profileTypeProperty);
profileSubtypeProperty.IsUserEditable = true;