Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在AD和SharePoint中同步员工组_Sharepoint - Fatal编程技术网

在AD和SharePoint中同步员工组

在AD和SharePoint中同步员工组,sharepoint,Sharepoint,员工或任何其他广告组与SharePoint 2007的同步 目前,AD和SharePoint中都有一个员工组 我们需要一个批处理脚本,或者工作流,或者任何保持这些组同步的东西 应为单向同步,Active Directory为主控,SharePoint为副本 它应该每小时自动同步一次,我们应该能够在任何时候手动执行同步 它不应删除组并重新填充。这将意味着有一段时间没有人可以进入 执行此操作的最佳方法是什么?您是否在SharePoint网站上使用Windows身份验证 如果是,则不需要脚本来保持

员工或任何其他广告组与SharePoint 2007的同步

目前,AD和SharePoint中都有一个员工组

  • 我们需要一个批处理脚本,或者工作流,或者任何保持这些组同步的东西
  • 应为单向同步,Active Directory为主控,SharePoint为副本
  • 它应该每小时自动同步一次,我们应该能够在任何时候手动执行同步
  • 它不应删除组并重新填充。这将意味着有一段时间没有人可以进入

执行此操作的最佳方法是什么?

您是否在SharePoint网站上使用Windows身份验证

如果是,则不需要脚本来保持组同步。。他们将自己保持同步。从广告组中删除用户也会将其从SharePoint组中删除

不过,您可能会遇到一些延迟,这可能是您认为需要脚本的原因(应该不会超过15分钟)

如果你赶时间,你可以做一个IISReset,你应该马上看到你的改变


如果未使用Windows Auth,或者SharePoint组与AD组不同,则需要添加同步例程

您最好的选择可能是每x分钟运行一次代码(或SSIS包)。在循环中,检查广告组的每个成员。验证它们是否在SharePoint组中。如果没有,请使用如下代码:

using (SPWeb oWebsiteRoot = SPContext.Current.Site.RootWeb)
{
    //Loop through your AD group here
    oWebsiteRoot.AllowUnsafeUpdates = true;
    oWebsiteRoot.Groups["Employee"].AddUser(username, email, fullname, String.Empty);
    oWebsiteRoot.Update();
}
网站是您的网站集,用户拥有您需要的所有信息。这将创建SharePoint用户并将其添加到组中

完成后,检查每个SharePoint用户并验证他们是否在广告组中。如果它们不是,请删除它们:

using (SPWeb oWebsiteRoot = SPContext.Current.Site.RootWeb)
{
    SPGroupCollection collGroups = oWebsiteRoot.SiteGroups;
    SPUser oUser = oWebsiteRoot.Users["User_Name"];

    foreach (SPGroup oGroup in collGroups)
    {
        oGroup.RemoveUser(oUser);
    }
}

我们正在使用windows授权。配置文件设置为与共享服务用户配置文件导入服务中的增量导入同步。我们只能使用SharePoint计划每天导入/同步一次。我们希望能更频繁地这样做,比如每小时一次,并且能够在需要的时候手动完成。然后我给你的代码应该可以做到这一点。如果您想按需手动执行,请将其包装在web部件中。