Sharepoint从User Profile中取信息备忘

一种方法是通过sp提供的webservice来取,webservice地址为:http(s)://站点地址/_vti_bin/UserProfileService.asmx?WSDL

再一种是通过Microsoft.Office.Server.UserProfiles来取,取时要添加命名空间:

using Microsoft.Office.Server;
using Microsoft.Office.Server.UserProfiles;
using Microsoft.SharePoint;

大概代码如下:

using (SPSite site = new SPSite(_spsite))
            {
                SPServiceContext context = SPServiceContext.GetContext(site);
                UserProfileManager pmManager = new UserProfileManager(context);
                System.Collections.IEnumerator item = pmManager.GetEnumerator();
                
                while (item.MoveNext())
                {
                    UserProfile userProfile = item.Current as UserProfile;
                    object o = userProfile[PropertyConstants.Url].Value;
                    var accCountObj= userProfile[PropertyConstants.AccountName].Value;
                    var DepartmentObj = userProfile[PropertyConstants.Department].Value;
                    var DCIdObj = userProfile[PropertyConstants.DCId].Value;
                    var DomainObj = userProfile[PropertyConstants.Domain].Value;
                    var MemberObj = userProfile[PropertyConstants.Member].Value;
                    
                }
            }

  

posted on 2020-09-20 21:55  ymworkroom  阅读(71)  评论(0)    收藏  举报