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

转载于:https://www.cnblogs.com/IsNull/archive/2010/11/24/1886859.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值