Nishand's Blog

Welcome to my personal blog, All the information in this bogs is my ideas,findings and thoughts on .Net, Asp.Net and SharePoint.
ALL POSTING ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND

UserProfileManager object creating fails when we try to create an instance from a SharePoint workflow application.

A work-around to this issue is, execute the code under admin privileges(impersonate the user), you can either follow the Win API impersonation or using the SPSecurity.RunWithElevatedPrivilages() method.

You would get errors like,

'Microsoft.SharePoint.SPException'

base {System.ApplicationException}: {"Cannot complete this action.\n\nPlease try again."}

ErrorCode: -2147467259

UserProfileChangeJobSchedule: 'new UserProfileManager(context,false).UserProfileChangeJobSchedule' threw an exception of type 'Microsoft.SharePoint.SPException'

SPSecurity.RunWithElevatedPrivilages(delegate()

{

ServerContext context = ServerContext.GetContext("SharedServices2");

UserProfileManager manager = new UserProfileManager(context);

});

 

Published Sunday, May 20, 2007 10:18 PM by nishandv
Filed under:

Comments

No Comments
Anonymous comments are disabled

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker