求救高手:infoPath表单发布到sharepoint上,读取userprofile出错

rickyll 2009-12-31 04:57:01
我在 infoPath2007 读取userProfile代码片段,当表单发布之后,代码执行到 “if (profileManager.UserExists("mosscn \\username"))” 报错“对象的当前状态使该操作无效”,有高手知道怎样解决吗?

(备注:没发布前 在infoPath浏览测试,代码是成功的)


PSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite("http://mosscn"))
{
using (SPWeb web = site.OpenWeb())
{
web.AllowUnsafeUpdates = true;
ServerContext context = ServerContext.GetContext(site);
UserProfileManager profileManager = new UserProfileManager(context);
if (profileManager.UserExists("mosscn \\username"))
{
.....


另外请教表单发布后能逐句调试吗?
...全文
99 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
rickyll 2010-01-04
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 time_is_life 的回复:]
C# code

SPSite site=null;
SPWeb web=null;
PSecurity.RunWithElevatedPrivileges(delegate()
{
site=new SPSite("http://mosscn");
?-
[/Quote]

time_is_life写的代码我没测试,问题自己解决了,需要通过WEB SERVICE方式访问。。。。。
time_is_life 2009-12-31
  • 打赏
  • 举报
回复


SPSite site = null;
SPWeb web = null;
PSecurity.RunWithElevatedPrivileges(delegate()
{
site = new SPSite("http://mosscn");
web = site.OpenWeb();
}); //RunWithElevatedPrivileges 结束。

web.AllowUnsafeUpdates = true;
ServerContext context = ServerContext.GetContext(site);
UserProfileManager profileManager = new UserProfileManager(context);
if (profileManager.UserExists("mosscn \\username"))
{
.....


if( web != null )
{
web.Dispose();
}

if( site!= null )
{
site.Dispose();
}



rickyll 2009-12-31
  • 打赏
  • 举报
回复
up

3,245

社区成员

发帖
与我相关
我的任务
社区描述
企业开发 SharePoint
社区管理员
  • SharePoint社区
  • 霖雨 - LinyuLoveTJ
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧