zoukankan      html  css  js  c++  java
  • ?????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了。

  • 相关阅读:
    20145312 《信息安全系统设计基础》实验三 实时系统的移植(修改版)
    20145312《信息安全系统设计基础》课程总结
    《信息安全系统设计基础》实验三 《实时系统的移植》 问题总结
    《信息安全系统设计基础》实验五 《网络通信》 问题总结

    20145309 《网络对抗技术》信息搜集与漏洞扫描
    20145309李昊《网络对抗》MSF应用基础
    20145309 《网络攻防》恶意代码分析
    20145309《网络对抗技术》免杀原理与实践
    20145309 李昊 《网络攻防》 Exp2 后门原理与实践
  • 原文地址:https://www.cnblogs.com/IsNull/p/1886859.html
Copyright © 2011-2022 走看看