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了。

  • 相关阅读:
    发红包案列——继承和集合
    抽象类
    方法重写
    继承——访问成员变量,访问成员方法,访问构造方法
    js异步计时器
    栈(stack)和堆(heap)
    高并发和多线程概念
    集群、负载均衡、分布式、微服务
    Redis性能监控
    Redis配置
  • 原文地址:https://www.cnblogs.com/IsNull/p/1886859.html
Copyright © 2011-2022 走看看