Sharepoint 2007 SharePoint用户配置文件搜索

Sharepoint 2007 SharePoint用户配置文件搜索,sharepoint-2007,profiles,Sharepoint 2007,Profiles,有没有办法从对象模型中搜索MOSS中的配置文件?我需要搜索在其配置文件上设置了特定值的配置文件,然后为它们执行一些操作 我需要写一些c代码,可以搜索配置文件数据库,并返回匹配的配置文件。基本上 配置文件列表=从配置文件存储中选择配置文件,其中配置文件属性值=SomeValue 我试图避免以下情况: private IEnumerable<UserProfile> SearchProfiles(string value) { ServerContext serverC

有没有办法从对象模型中搜索MOSS中的配置文件?我需要搜索在其配置文件上设置了特定值的配置文件,然后为它们执行一些操作

我需要写一些c代码,可以搜索配置文件数据库,并返回匹配的配置文件。基本上

配置文件列表=从配置文件存储中选择配置文件,其中配置文件属性值=SomeValue

我试图避免以下情况:

 private IEnumerable<UserProfile> SearchProfiles(string value) {
        ServerContext serverContext = ServerContext.GetContext(SPContext.Current.Site);
        UserProfileManager profileManager = new UserProfileManager(serverContext);
        foreach (UserProfile profile in profileManager) {
            if ((string)profile["MyProp"].Value == value) {
                yield return profile;
            }
        }
    }

这可以通过使用FullTextSqlQuery类实现:

FullTextSqlQuery q = new FullTextSqlQuery(ServerContext.Current);
q.ResultTypes = ResultType.RelevantResults;
q.QueryText = "SELECT UserName, Email, PreferredName FROM SCOPE() WHERE \"scope\" = 'People' AND Department = 'IT'";

ResultTableCollection tables = q.Execute();
ResultTable results = tables[ResultType.RelevantResults];
此类允许您查询特定范围,即人员,并使用WHERE子句根据属性对其进行筛选,WHERE子句与常规Sql查询基本相同

为了能够搜索和筛选自定义用户配置文件属性,配置文件属性需要在共享服务提供商的元数据设置中具有映射。大多数开箱即用的用户配置文件属性已经具有这些自定义属性,您必须自己添加这些属性


有关托管属性的详细信息。

这可以使用FullTextSqlQuery类:

FullTextSqlQuery q = new FullTextSqlQuery(ServerContext.Current);
q.ResultTypes = ResultType.RelevantResults;
q.QueryText = "SELECT UserName, Email, PreferredName FROM SCOPE() WHERE \"scope\" = 'People' AND Department = 'IT'";

ResultTableCollection tables = q.Execute();
ResultTable results = tables[ResultType.RelevantResults];
此类允许您查询特定范围,即人员,并使用WHERE子句根据属性对其进行筛选,WHERE子句与常规Sql查询基本相同

为了能够搜索和筛选自定义用户配置文件属性,配置文件属性需要在共享服务提供商的元数据设置中具有映射。大多数开箱即用的用户配置文件属性已经具有这些自定义属性,您必须自己添加这些属性

有关托管属性的更多信息。

两件事:

当以提升的权限运行时,我们需要在调用中创建一个新的SPSite对象,并从中加载安全上下文。不要使用通过SPContext.Current.Site获得的上下文

因此:

SPSecurity.RunWithElevatedPrivileges(delegate()
{
 using (SPSite site = new SPSite("<your site url>"))
 {
  ServerContext context = ServerContext.GetContext(site);

  UserProfileManager profileManager = new

  UserProfileManager(context);

  foreach (UserProfile profile in profileManager)
  {
   // your code
  }
 }
}
确保应用程序池帐户在SSP中具有适当的用户权限。i、 e.使用个人功能,管理用户档案

两件事:

当以提升的权限运行时,我们需要在调用中创建一个新的SPSite对象,并从中加载安全上下文。不要使用通过SPContext.Current.Site获得的上下文

因此:

SPSecurity.RunWithElevatedPrivileges(delegate()
{
 using (SPSite site = new SPSite("<your site url>"))
 {
  ServerContext context = ServerContext.GetContext(site);

  UserProfileManager profileManager = new

  UserProfileManager(context);

  foreach (UserProfile profile in profileManager)
  {
   // your code
  }
 }
}
确保应用程序池帐户在SSP中具有适当的用户权限。i、 e.使用个人功能,管理用户档案


6年后,我知道,但为什么我不能将RunWithElevatedPrivileges与SPContext.Current.Site一起使用?6年后,我知道,但为什么我不能将RunWithElevatedPrivileges与SPContext.Current.Site一起使用?