0
Fixed

SharePoint 2010 User Profile Service cannot import larger numbers of users by default

Matthew Clark 13 years ago in UNIFYBroker/Microsoft SharePoint updated by anonymous 9 years ago 7

When attempting to retrieve user profiles from SharePoint 2010, the following error was thrown on the SharePoint side. Note that this is from a WCF trace on the SharePoint side - the error message thrown to Identity Broker is not at all helpful:

There was an error while trying to serialize parameter http://www.unifysolutions.net/IdentityBroker/SharePoint:GetProfilePageResult. The InnerException message was 'Maximum number of items that can be serialized or deserialized in an object graph is '65536'. Change the object graph or increase the MaxItemsInObjectGraph quota. '.  Please see InnerException for more details.

Error thrown to Identity Broker:

Error occurred in module: Change detection engine

Change detection engine poll for connector SharePoint 2010 User Profile Connector failed with reason An error occurred while receiving the HTTP response to http://c21sharepoint/_vti_bin/unify/userprofile.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.. Duration: 00:01:13.9003906
Error details:
System.ServiceModel.CommunicationException: An error occurred while receiving the HTTP response to http://c21sharepoint/_vti_bin/unify/userprofile.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
   --- End of inner exception stack trace ---
   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.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 Unify.Communicators.UserProfileManager.ISharePoint2010UserProfileService.GetProfilesByName(String[] accountNames)
   at Unify.Connectors.SharePoint2010UserProfileConnector.GetEntities(IEnumerable`1 entityIds)
   at Unify.Framework.ConnectorToPollingConnectorBridge.GetEntities(IEnumerable`1 entityIds)
   at Unify.Framework.EventNotifierReadingConnectorDecoratorBase`1.GetEntities(IEnumerable`1 entityIds)
   at Unify.Framework.ChangeDetectionPollJob.RunBase()
   at Unify.Framework.MutexJobDecorator.Run()
   at Unify.Framework.DefinedScopeJobAuditTrailJobDecorator.Run()
   at Unify.Framework.AsynchronousJobExecutor.PerformJobCallback(Object state)

The workaround is to decrease the number of users retrieved from SharePoint at a time using the bulkPageSize property of the communicator. However, the above attribute should be changed programmatically in the WCF service itself. SharePoint 2010 allocates a dynamic schema to all custom WCF services - see http://msdn.microsoft.com/en-us/library/ff521586.aspx.

Quota has been increased. To be tested.

Issues with permissions. Modifications made according to http://shaunedonohue.blogspot.com/2011/03/reader-quotas-for-wcf-services-in_4706.html and related articles. Currently testing.

After making the above changes, the issue is still persisting. It is not that the WCF settings are not being properly set using this mechanism - I have been able to confirm that the methods are successfully being called by creating some null references. It is that the MaxItemsInObjectGraph property is not being affected by the setting of the other properties. For some strange reason, most other reader quota settings can be set using the SPWcfServiceSettings object, but apparently not this one (see http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spwcfservicesettings_members.aspx). The most similar issue like this I have been able to find (when it turned out that the other properties being too low has had no bearing on the number of items in the graph, of which there are plenty of issues) has been http://social.technet.microsoft.com/Forums/en/sharepoint2010setup/thread/f095d557-a14a-4d58-9c05-aa8474300625, where the Microsoft response has been to edit the web.config relating to this service. However, with custom WCF services, dynamic configuration is used by SharePoint (see the article in the original issue), so this may be more difficult. Further investigation is required, and the path of a supplementary web.config file may need to be taken.

Attempting to change the MaxItemsInObjectGraph property of the service behaviours has had no effect. Continued investigation has not proven fruitful so far - I have not been able to find any other users experiencing this problem. Created a question on Stack Overflow - http://stackoverflow.com/questions/6838047/sharepoint-2010-wcf-service-maxitemsinobjectgraph-problem. Some sites have suggested manually updating the root web.config of the SharePoint instance, but this needs to be done for every machine in a farm, and is not easily maintainable or configurable.

Verified the GAC was correctly refreshing on deployment. http://stackoverflow.com/questions/6298209/how-to-fix-maxitemsinobjectgraph-error indicates that this problem was solved by setting the configuration on the client side (in our case, the connector). Begun setting this up. The Identity Broker service configuration should be setting this value correctly, but this is still something I would like to check.

The above resolved the issue - see http://stackoverflow.com/questions/6838047/sharepoint-2010-wcf-service-maxitemsinobjectgraph-problem. Tested and profiles are correctly retrieved using default settings. Please confirm in next candidate.