private static void AddADObject(ModifiedItem item) { var oguObject = item.OguObjectData; string[] rdns = SynchronizeHelper.GetOguObjectRdns(oguObject); string parentDN = string.Join(",", rdns, 1, rdns.Length - 1); ADHelper adHelper = SynchronizeContext.Current.ADHelper; using (DirectoryEntry parentEntry = parentDN.IsNullOrEmpty() ? adHelper.GetRootEntry() : adHelper.NewEntry(parentDN)) { parentEntry.ForceBound(); using (DirectoryEntry newEntry = WhatEverNewEntry(oguObject, parentEntry)) { ObjectSetterHelper.Convert(ObjectModifyType.Add, oguObject, newEntry); //item.ADObjectData = SynchronizeHelper.GetSearchResultByID(newEntry.NativeGuid, newEntry.ToADSchemaType()).ToADOjectWrapper(); if (SynchronizeContext.Current.IDMapper.NewIDMappingDictionary.ContainsKey(oguObject.ID) && SynchronizeContext.Current.IDMapper.NewIDMappingDictionary[oguObject.ID] == null) { SynchronizeContext.Current.IDMapper.NewIDMappingDictionary[oguObject.ID] = new IDMapping() { SCObjectID = oguObject.ID, ADObjectGuid = newEntry.NativeGuid, LastSynchronizedVersionTime = (DateTime)oguObject.Properties["VERSION_START_TIME"] }; } } } }
private static void DeleteADObject(ObjectModifyType modifyType, IOguObject oguObject, ADObjectWrapper adObject) { ADHelper adHelper = SynchronizeContext.Current.ADHelper; using (DirectoryEntry entry = SynchronizeHelper.GetSearchResultByID(adHelper, adObject.NativeGuid).GetDirectoryEntry()) { entry.ForceBound(); ObjectSetterHelper.Convert(modifyType, oguObject, entry); } }
private static void ModifyADObjectProperties(ObjectModifyType modifyType, ModifiedItem item) { IOguObject oguObject = item.OguObjectData; ADObjectWrapper adObject = item.ADObjectData; using (DirectoryEntry entry = SynchronizeHelper.GetSearchResultByID(SynchronizeContext.Current.ADHelper, adObject.NativeGuid, (ADSchemaType)oguObject.ObjectType).GetDirectoryEntry()) { entry.ForceBound(); ObjectSetterHelper.Convert(modifyType, oguObject, entry); } }