如何在SharePoint 2010中获取用户配置文件属性? [英] How to get user profile properties in SharePoint 2010?
问题描述
大家好,
我正在使用SharePoint 2010平台和Visual Studio 2010.
如何使用客户端编码或服务器端编码在SharePoint 2010中检索用户配置文件属性?
我已经在下面引用了参考文献,但是对于在SharePoint 2010中是否可以使用它,我有些困惑-
https://msdn.microsoft.com/zh-cn/library/office/ms544366(v = office.14).aspx
https://docs.microsoft.com/zh-cn/sharepoint/dev/general-development/how-to-retrieve-user-profile-properties-by-using-the-net-client-object-model -in
所以请提出建议.
感谢任何帮助/建议.
巴拉吉
您可以查看以下代码:
确保您添加了引用
结果:
您可以从获取用户配置文件属性名称. 这里
此致
Priyan
Hello Everyone,
I am working on SharePoint 2010 platform and visual Studio 2010.
How can i retrieve user profile properties in SharePoint 2010 by using Client side coding or Server side coding?
I already referred below references but i am bit confused whether its possible in SharePoint 2010 or not -
https://msdn.microsoft.com/en-us/library/office/ms544366(v=office.14).aspx
https://docs.microsoft.com/en-us/sharepoint/dev/general-development/how-to-retrieve-user-profile-properties-by-using-the-net-client-object-model-in
So please suggest.
Appreciating any help/Suggestions.
Balaji
Hi,
You may check out the below code :
Ensure that you add the references
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Office.Server; using Microsoft.Office.Server.UserProfiles; using Microsoft.SharePoint; namespace GetUserProfileService { class Program { static void Main(string[] args) { GetUserProfile(); } public static void GetUserProfile() { using (SPSite siteCollection = new SPSite("http://demo1/")) { using (SPWeb site = siteCollection.OpenWeb()) { ServerContext context = ServerContext.GetContext(siteCollection); UserProfileManager upm = new UserProfileManager(context); SPUserCollection userCollection = site.AllUsers; Microsoft.Office.Server.UserProfiles.PropertyCollection props = upm.Properties; foreach (Property prop in props) { Console.WriteLine(prop.Name.ToString()); } //foreach (UserProfile profile in upm) //{ // Console.WriteLine(profile["WorkEmail"].ToString()); //} foreach (SPUser spUser in userCollection) { if (spUser.LoginName.ToString() != "NT AUTHORITY\\LOCAL SERVICE" && spUser.LoginName.ToString() != "SHAREPOINT\\system") { UserProfile profile = upm.GetUserProfile(spUser.LoginName); Console.WriteLine(spUser.LoginName + "'s workemail : " + (string)profile["WorkEmail"].Value); Console.WriteLine(spUser.LoginName + "'s Account name : " + (string)profile["AccountName"].Value); } } Console.ReadLine(); } } } } }Result:
You can get the User Profile Property names from here
Regards,
Priyan
这篇关于如何在SharePoint 2010中获取用户配置文件属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!