使用 SharePoint 2010 Client Object Model 修改用户Email(邮箱) 地址
2011-09-03 10:20
471 查看
我们使用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
本文介绍如何使用 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 for JavaScript (ECMAScript)(使用客户端对象模型)
- 使用Jscex增强SharePoint 2010 JavaScript Client Object Model (JSOM)
- [SharePoint 2010] Javascript Client Object Model 在SharePoint2010中的使用方法
- SharePoint 2010新特性使用Client Object Model在客户端开发
- SharePoint 2010新特性使用Client Object Model在客户端开发
- SharePoint 2010 匿名用户调用Client Object Model访问列表项
- sharepoint 2007 修改用户和组 display name 和 email地址 代码
- 总结:Sharepoint2010 Client Object Model -- 获得Sharepoint 网站当前用户
- [SharePoint 2010] Client Object Model 跨时区查询list item的方法
- 在C#开发中如何使用Client Object Model客户端代码获得SharePoint 网站、列表的权限情况
- SharePoint 2013/2010 使用Silverlight client model
- 使用SharePoint 2010的PowerShell完成Object Model编程才能完成的功能的一个实例
- Sharepoint2010应用开发四:使用客户对象模型(Client Object Model)向SharePoint列表写数据
- [SharePoint 2010] Client Object Model 跨时区查询list item的方法
- SharePoint 2010 Client Object Model-Client API
- 使用ClientObjectModel访问SharePoint数据
- SharePoint 2010 Client Object Model - JavaScript(ECMAScript)
- [SharePoint 2010] 使用Designer 2010修改List item的链接地址
- 如何开启匿名访问SharePoint 2010里的Client Object Model
- Sharepoint 2010 client object model