会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
Nirvanalst
博客园
首页
新随笔
联系
管理
订阅
通过程序将UserProfile中用户导入到指定SharePoint用户组
Code
1
using
(SPSite site
=
new
SPSite(
"
http://itsmossserver:81
"
))
2
{
3
//
用户组
4
SPGroup sealerGroup
=
site.RootWeb.SiteGroups[
"
销售人员
"
];
5
ServerContext context
=
ServerContext.GetContext(site);
6
UserProfileManager profiles
=
new
UserProfileManager(context);
7
//
出现异常日志
8
StreamWriter writer
=
File.CreateText(
"
d:\\userLog.txt
"
);
9
string
loginName
=
""
;
10
string
dispName
=
""
;
11
string
email
=
""
;
12
//
遍历UserProfile集合
13
foreach
(UserProfile profile
in
profiles)
14
{
15
try
16
{
17
loginName
=
profile.MultiloginAccounts[
0
];
18
dispName
=
profile[
"
PreferredName
"
].ToString();
19
email
=
profile[
"
UserName
"
].ToString()
+
"
@dc.com
"
;
20
//
向用户组添加用户
21
sealerGroup.AddUser(loginName, email, dispName,
""
);
22
Console.WriteLine(profile.MultiloginAccounts[
0
]
+
"
;
"
+
dispName
+
"
OK!
"
);
23
}
24
catch
(Exception)
25
{
26
writer.WriteLine(loginName
+
"
#
"
+
dispName);
27
}
28
}
29
writer.Dispose();
30
writer.Close();
31
}
posted @
2009-11-03 11:42
nirvanalst
阅读(
446
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
公告