// 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); } }