private void SyncObjectsFromAD(SyncTree syncTree,
ADObjectType objType,
SearchResultCollection allADObjects,
Action<DirectoryEntry, string, Guid, SyncTree> CreateNewObject,
Action<DirectoryEntry, Node, SyncTree> UpdateProperties)
{
foreach (SearchResult result in allADObjects)
{
try
{
string nodeADpath = result.Path;
if (syncTree.IsADPathExcluded(nodeADpath))
continue;
AdLog.LogOuterADObject("Syncing", result.Path);
var guid = Common.GetADResultGuid(result, _config.GuidProp);
if (!guid.HasValue)
{
// no AD guid present for object
AdLog.LogErrorADObject("No AD GUID present", result.Path);
continue;
}
// új objektumok (ou, user, group) felvétele, átmozgatások
// - ha létezik az adott guid-ú objektum -> path ellenőrzés, átmozgatás
// - ha nem létezik, létrehozás
string nodePortalParentPath = syncTree.GetPortalParentPath(nodeADpath);
if (!Node.Exists(nodePortalParentPath))
{
// adpath: OU=OtherOrg,OU=ExampleOrg,DC=Nativ,DC=local
// portalParentPath: "/Root/IMS/NATIV/ExampleOrg"
EnsurePortalPath(syncTree, syncTree.GetADParentObjectPath(result.Path), RepositoryPath.GetParentPath(nodePortalParentPath));
}
SyncOneADObject(result, null,
(Guid)guid,
objType,
nodePortalParentPath,
CreateNewObject,
UpdateProperties,
syncTree);
}
catch (Exception ex)
{
// syncing of one object of the current tree failed
AdLog.LogException(ex);
}
}
}