使用 SharePoint 2010 Client Object Model 修改用户Email(邮箱) 地址
来源:互联网 发布:直销软件系统 编辑:程序博客网 时间:2024/05/21 11:10
我们使用SharePoint 2010 时,有时需要修改用户Email(邮箱) 地址,但是People and Groups 这个列表里面不允许我们修改。
本文介绍如何使用 Client Object Model 来修改用户Email(邮箱) 地址。
关于如何使用Moss 2010 Client Object Model,请参考 http://msdn.microsoft.com/en-us/library/ee857094.aspx#Y5816
using System;using System.Collections.Generic;using System.Linq;using System.Text;using Microsoft.SharePoint.Client;namespace ConsoleApplication1{ class Program { static void Main(string[] args) { // init the ClientContext, please replace the website url with the moss 2010 site url you want to access string siteUrl = "http://ccpc"; ClientContext clientContext = new ClientContext(siteUrl); // Get the user info list of the web site List userList = clientContext.Web.SiteUserInfoList; clientContext.Load(userList); clientContext.ExecuteQuery(); Console.WriteLine(userList.ItemCount); // Get the fields of the list FieldCollection fc = userList.Fields; clientContext.Load(fc); clientContext.ExecuteQuery(); // Print fc foreach (Field field in fc) { Console.WriteLine(field.InternalName); } // Get the ListItem collection CamlQuery camlQuery = new CamlQuery(); camlQuery.ViewXml = @"<View> </View>"; ListItemCollection itemList = userList.GetItems(camlQuery); // Only load the two fields(EMail and Name) clientContext.Load(itemList, items => items .Include( item => item["EMail"], item => item["Name"])); clientContext.ExecuteQuery(); // Print the email and user name string messageTemplate = "Name ={0}, Email = {1}"; foreach (ListItem item in itemList) { string[] alias= item["Name"].ToString().Split("\\".ToCharArray()); Console.WriteLine(string.Format(messageTemplate, item["Name"], item["EMail"])); // Update the user email, replace the james.com with your owner mail server adress if (alias.Length == 2) { item["EMail"] = alias[1] + "@james.com"; } else { item["EMail"] = alias[0] + "@james.com"; } item.Update(); } // submit the update clientContext.ExecuteQuery(); Console.Read(); } }}
- 使用 SharePoint 2010 Client Object Model 修改用户Email(邮箱) 地址
- SharePoint 2010 Client Object Model-Client API
- SharePoint 2010 Client Object Model - JavaScript(ECMAScript)
- SharePoint 2010 匿名用户调用Client Object Model访问列表项
- SharePoint 2013/2010 使用Silverlight client model
- sharepoint 2007 修改用户和组 display name 和 email地址 代码
- 如何开启匿名访问SharePoint 2010里的Client Object Model
- Get the metadata value using client object model from the sharepoint 2010
- Sharepoint的客户端对象模型(Client Object Model)(转)
- Sharepoint Client Object Model 之 开发基于.NET的应用程序
- SharePoint Client Object Model API 介绍以及工作原理解析
- HTML <a> 标签 (修改样式,链接邮箱Email地址)
- HTML <a> 标签 (修改样式,链接邮箱Email地址)
- Using the SharePoint 2010 Client Object Model_part_1
- Using the SharePoint 2010 Client Object Model_part_2
- Using the SharePoint 2010 Client Object Model_part_3
- Using the SharePoint 2010 Client Object Model_part_4
- Using the SharePoint 2010 Client Object Model_part_5
- 定义判断每日练习及精解20110829
- 浅谈Android系统的图标设计规范
- .NET设计模式(2):单件模式(Singleton Pattern)
- CGI小结
- Facade模式
- 使用 SharePoint 2010 Client Object Model 修改用户Email(邮箱) 地址
- C++ vector容器类型
- 查看并解锁对数据库加锁的session
- VB 学习笔记
- SQL Server FOR XML PATH 语句的应用
- win7 下完美解决VB 动态添加的flash 控件 fscommand 消息未触发的方法
- 杭电1005
- 编写软件架构文档说明
- 敏捷开发为何难有“最佳实践”