示例#1
0
        // delete portal objects that have no corresponding synchronized objects in AD
        private void DeleteObjectsFromAD(SyncTree syncTree,
                                         ADObjectType objType,
                                         SearchResultCollection allADObjects,
                                         Action <Node> DeletePortalObject)
        {
            try
            {
                AdLog.LogOuter("Querying all portal objects...");
                var portalNodes = GetAllPortalObjects(objType, syncTree);
                AdLog.LogOuter("Checking if portal objects exist under synchronized path in AD...");
                foreach (Node node in portalNodes)
                {
                    try
                    {
                        // check if object exists under synchronized path in AD
                        var guid = Common.GetPortalObjectGuid(node);
                        if ((!guid.HasValue) || (!ADObjectPathSynced((Guid)guid, allADObjects, node)))
                        {
                            if (!guid.HasValue)
                            {
                                AdLog.Log(string.Format("No guid set for portal object: {0} ", node.Path));
                            }

                            // deleted from AD or not under synchronized path any more
                            DeletePortalObject(node);
                        }
                    }
                    catch (Exception ex)
                    {
                        AdLog.LogException(ex);
                    }
                }
            }
            catch (Exception ex)
            {
                AdLog.LogException(ex);
            }
        }
示例#2
0
        // checks if the AD object corresponding to the given portal guid exists under synchronized path - if not, it should be deleted from portal...
        private bool ADObjectPathSynced(Guid guid, SearchResultCollection ADObjects, Node node)
        {
            bool exists = false;

            foreach (SearchResult result in ADObjects)
            {
                if (Common.GetADResultGuid(result, _config.GuidProp) == guid)
                {
                    var nodeADpath = result.Path;
                    AdLog.Log(string.Format("AD object for portal object {0} (guid {1}) found ({2}), checking synctrees", node.Path, guid.ToString(), nodeADpath));

                    foreach (SyncTree syncTree in _syncTrees)
                    {
                        if (syncTree.ContainsADPath(nodeADpath))
                        {
                            return(true);
                        }
                    }
                    AdLog.Log(string.Format("No corresponding synctree for AD object ({0}) found, object should be deleted", nodeADpath));
                }
            }
            return(exists);
        }