• ?????Can't User UserProfileManager.GetUserProfile Get User Userprofile In Web Service(没解决的.只记录)


    E文环境提示:

    Error:
    System.ArgumentNullException: Value cannot be null.
    Parameter name: serverContext
    at Microsoft.Office.Server.SiteContext..ctor(ServerCo ntext serverContext)
    at Microsoft.Office.Server.SiteContext.get_Current()
    at Microsoft.Office.Server.UserProfiles.SRPSite.get_S iteContext()
    at
    Microsoft.Office.Server.UserProfiles.PropertyDataT ypeCollection..ctor(SRPSite
    site)
    at Microsoft.Office.Server.UserProfiles.SRPSite.get_D ataTypes()
    at
    Microsoft.Office.Server.UserProfiles.UserProfileMa nager.get_PropertyDataTypes()
    at Microsoft.Office.Server.UserProfiles.UserProfile.L oad(SqlDataReader
    myReader, Boolean bFirstRead, Boolean bWssId)
    at Microsoft.Office.Server.UserProfiles.UserProfile.L oad(SqlDataReader
    myReader)
    at Microsoft.Office.Server.UserProfiles.UserProfile.R etrieveUser(String
    strAcct, Guid gAcct, Byte[] bSid, Nullable`1 recordId, Boolean
    doNotResolveToMasterAccount)
    at
    Microsoft.Office.Server.UserProfiles.UserProfile.. ctor(UserProfileManager
    objManager, String strAcct, Boolean doNotResolveToMasterAccount, Boolean
    forceUserIsSelf)
    at
    Microsoft.Office.Server.UserProfiles.UserProfile.. ctor(UserProfileManager
    objManager, String strAcct)
    at
    Microsoft.Office.Server.UserProfiles.UserProfileMa nager.GetUserProfile(String
    strAccountName)

    中文环境提示

    System.ArgumentNullException: 值不能为空。参数名: serverContext 在 Microsoft.Office.Server.SiteContext..ctor(ServerContext serverContext) 在 Microsoft.Office.Server.SiteContext.get_Current() 在 Microsoft.Office.Server.UserProfiles.SRPSite.get_SiteContext() 在 Microsoft.Office.Server.UserProfiles.PropertyDataTypeCollection..ctor(SRPSite site) 在 Microsoft.Office.Server.UserProfiles.SRPSite.get_DataTypes() 在 Microsoft.Office.Server.UserProfiles.UserProfileManager.get_PropertyDataTypes() 在 Microsoft.Office.Server.UserProfiles.UserProfile.Load(SqlDataReader myReader, Boolean bFirstRead, Boolean bWssId) 在 Microsoft.Office.Server.UserProfiles.UserProfile.Load(SqlDataReader myReader) 在 Microsoft.Office.Server.UserProfiles.UserProfile.RetrieveUser(String strAcct, Guid gAcct, Byte[] bSid, Nullable`1 recordId, Boolean doNotResolveToMasterAccount) 在 Microsoft.Office.Server.UserProfiles.UserProfile..ctor(UserProfileManager objManager, String strAcct, Boolean doNotResolveToMasterAccount, Boolean forceUserIsSelf) 在 Microsoft.Office.Server.UserProfiles.UserProfile..ctor(UserProfileManager objManager, String strAcct) 在 Microsoft.Office.Server.UserProfiles.UserProfileManager.GetUserProfile(String strAccountName) 在 EDS.EntComm.WebService.EntCommWebService.GetMyDocument(String strAccount, String strPersonalSiteHost, UInt32 uintNumber)

    解决:

    把你的WebService发布到MOSS站点或一个独立站点的虚拟目录下。把应用程序池的“标识”-〉“配置”里的用户设成Administrator,不要试图在代码里用

    SPSecurity.RunWithElevatedPrivileges(delegate()或

    WindowsPrincipal wp = new WindowsPrincipal(WindowsIdentity.GetCurrent());
    IPrincipal pOldUser = HttpContext.Current.User;

    HttpContext.Current.User = pOldUser;

    的方式提升权限,反正我是没成功,去掉这些代码

    用Microsoft Visual Studio的Visual Studio Development Server也可以调试。

    关键步骤:

    Microsoft.Office.Server.ServerContext serverContext = Microsoft.Office.Server.ServerContext.GetContext(spPersonalSite);

    HttpContext.Current.Items["Microsoft.Office.ServerContext"] = serverContext;设置了就可以得到SSP的Context了。

  • 相关阅读:
    Enterprise Library 3.0 – April 2007 Released
    Static methods can not be called remotely
    BizTalk: 提高 BizTalk 编程能力的 8 点技巧和窍门(MSDN Magazine)
    Calling Stored Procedures Using the SQL Adapter
    BizTalk: Difference between (PassThruReceive, PassThruSend) and (XmlReceive, XmlSend) Biztalk Pipelines (For Beginners)
    BizTalk Exception: Cannot access a disposed object && Failed to serialize the message part "BankQuoteRequest" into the type "BankQuoteRequest"
    Oneway web service call in BizTalk Orchestration
    Create route in crossserver SSB
    BizTalk: PublisherSubscriber model and Binding
    BizTalk Exception: Calling web services with Mixed OneWay and SolicitResponse Operations
  • 原文地址:https://www.cnblogs.com/IsNull/p/1886859.html
Copyright © 2020-2023  润新知