April 16, 2014

User Profile JobTitle Property Returns Null


Using SharePoint Object Model, the JobTitle property will always return NULL value for all users, even when users have valid user profiles with available Job Title property and is accessible from CA.

Example: I highlighted the code where JobTitle returns Null:
bool UserExist = uprofileManager.UserExists(user.LoginName);
if (UserExist)
UserProfile userProfile = uprofileManager.GetUserProfile(user.LoginName);
returnValue = (String)userProfile[PropertyConstants.JobTitle].Value;

While the same user has a Job Title value in his user profile:

Digging for Answers:

- First, I made sure that Job Title property accessibility is set to 'Everyone' in Central Admin
- I elevated the code privileges by using SPSecurity.RunWithElevatedPrivilages code block
- Also while debugging the code, I made sure the user.LoginName variable is in format "Domain\Username"
- Also, found that code to read SPS-JobTitle property would return Null too:
returnValue = (String)userProfile["SPS-JobTitle"].Value; // returns null

- However, all other user profile PropertyConstant properties (like Office, HomePhone,..) are readable correctly for the same users:
PropertyCollection props = uprofileManager.Properties;
UserProfile userProfile = uprofileManager.GetUserProfile(user.LoginName);
foreach (Property prop in props)
    Console.WriteLine(prop.Name.ToString() + "=" + userProfile[prop.Name].Value);

I concluded that its not the code that has issues, so there must be something with 'Title' and 'SPS-JobTitle' properties preventing the code from reading them.

We know that Title and SPS-JobTitle are special properties linked to Metadata keywords when profile import takes place from Active Directory. The Metadata service is running on 2 servers: WFE & APP. From Central Administration, I can access the Metadata service normally, and see all the Enterprise keywords (System -> Keywords) in Metadata Term Store without an issue.

Okay, now let's have a look on ULS logs. I found errors & highlighted the important lines:

1) Error in Topology:
SharePoint Web Services Round Robin Service Load Balancer Event: EndpointFailure Process Name: UserProfileImport Process ID: 10560 AppDomain Name: UserProfileImport.exe AppDomain ID: 1 Service Application Uri: urn:schemas-microsoft-com:sharepoint:service:02cb72f4a15149bd848db2ba8ab1f055#authority=urn:uuid:235674f601ec4ef1ae9cb964c49bf0d6&authority=https://usascsppro03-nt:32844/Topology/topology.svc Active Endpoints: 1 Failed Endpoints:1 Affected Endpoint: http://usascsppro04-nt:32843/02cb72f4a15149bd848db2ba8ab1f055/MetadataWebService.svc

2) Then error in Manages Metadata service:
Failed to get term store for proxy 'Managed Metadata Service'. Exception: System.ServiceModel.ServerTooBusyException: The HTTP service located
 at http://usascsppro04-nt:32843/02cb72f4a15149bd848db2ba8ab1f055/MetadataWebService.svc is too busy.  ---> System.Net.WebException: The remote server returned an error: (503) Server Unavailable.   
 at System.Net.HttpWebRequest.GetResponse()    
 at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)     -
 -- End of inner exception stack trace ---    Server stack trace:    
 at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)   
 at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)   
 at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)   
 at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request(Message message, TimeSpan timeout)   
 at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)   
 at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)   
 at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)   
 at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)    Exception rethrown
 at [0]:    
 at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)   
 at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)   
 at Microsoft.SharePoint.Taxonomy.IMetadataWebServiceApplication.GetServiceSettings(Guid rawPartitionId)   
 at Microsoft.SharePoint.Taxonomy.MetadataWebServiceApplicationProxy.<>c__DisplayClass2f.<ReadApplicationSettings>b__2e(IMetadataWebServiceApplication serviceApplication)   
 at Microsoft.SharePoint.Taxonomy.MetadataWebServiceApplicationProxy.<>c__DisplayClass2c.<RunOnChannel>b__2b()   
 at Microsoft.Office.Server.Security.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)   
 at Microsoft.SharePoint.Taxonomy.MetadataWebServiceApplicationProxy.<>c__DisplayClass2c.<RunOnChannel>b__2a()   
 at Microsoft.Office.Server.Utilities.MonitoredScopeWrapper.RunWithMonitoredScope(Action code)   
 at Microsoft.SharePoint.Taxonomy.MetadataWebServiceApplicationProxy.RunOnChannel(CodeToRun codeToRun, Double operationTimeoutFactor)   
 at Microsoft.SharePoint.Taxonomy.MetadataWebServiceApplicationProxy.ReadApplicationSettings(Guid rawPartitionId)   
 at Microsoft.SharePoint.Taxonomy.MetadataWebServiceApplicationProxy.GetTermStoreId(Guid rawPartitionId)   
 at Microsoft.SharePoint.Taxonomy.Internal.DataAccessManager.GetTermStoreData(MetadataWebServiceApplicationProxy sharedServiceProxy)

3) Then a warning:
The managed Metadata Service ‘Managed Metadata Service’ is inaccessible.

Interestingly, when browsing the Metadata service in IIS:
- MetadataWebService.svc is not available in WFE server (HTTP Error 503)
- MetadataWebService.svs is available in APP server

Root Cause:

It appeared that this all related to an issue Managed Metadata service leading to the issue in SharePoint topology (load balancer) service officially known as "Application Discovery and Load Balancer Service Application".

The Managed Metadata service was setup to work on both WFE and APP servers. on WFE, the Metadata was not working as we saw the HTTP error 503. But that was not a problem since the other Metadata service works fine on the APP server, hence the perfectly fine keywords & user profile accessibility. However, the topology (load balancer) service was having an issue, because it basically round-robin requests to services if we have more than one server to offer these services. Since the Metdata data service is not working in WFE then it's end-point will not be valid. But topology service still thinks it is a perfectly valid end-point and keep trying to connect to the Metdata service through that faulty endpoint, until a connection time-out occurs and a 'server unavailable' exception is thrown in log.


  1. Stop the faulty Managed Metadata service (in this case on WFE) from CA             
  2. In some cases, you need to stop/start Metadata service on other server too to refresh the endpoints
  3. Stop then restart the application pool of faulty Topology application from IIS (in this case on WFE)
  4. Make sure all application pools are started normally


After applying steps above, the Metadata term store & User profiles work normally. Code able to read the values for JobTitle property for all users.

Useful resources:

No comments:

Post a Comment