protected override bool ComparePropertyValue(IOguObject srcOguObject, string srcPropertyName, ADObjectWrapper adObject, string targetPropertyName, string context) { DateTime dtResult = DateTime.MinValue; long adAccountExpiresValue = Convert.ToInt64(adObject.Properties[targetPropertyName]); try { if (adAccountExpiresValue != SynchronizeHelper.ACCOUNT_EXPIRES_MAX_VALUE) { if (adAccountExpiresValue != 0) { DateTime dt = DateTime.FromFileTime(adAccountExpiresValue); //舍弃掉毫秒 dtResult = new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second, dt.Millisecond); } } } catch (System.ArgumentOutOfRangeException) { dtResult = DateTime.MaxValue; } dtResult = SynchronizeContext.Current.ADHelper.GetUserAccountExpirationDate(dtResult); var accountExpiresDate = Convert.ToDateTime(srcOguObject.Properties[srcPropertyName]); return accountExpiresDate == dtResult; }
private static bool IsChildrenModified(IOguObject oguObject, ADObjectWrapper targetObject) { ADHelper adHelper = SynchronizeContext.Current.ADHelper; SearchResult result = SynchronizeHelper.GetSearchResultByDN(adHelper, targetObject.DN, ADSchemaType.Groups); //当前肯定有改组存在 ResultPropertyValueCollection adMembers = result.Properties["member"]; IUser[] oguUsers = ((IGroup)oguObject).Members.Where(u => u.FullPath.StartsWith(SynchronizeContext.Current.StartPath) && u.IsSideline == false).ToArray(); if (adMembers.Count != oguUsers.Count()) return true; foreach (var memberDN in adMembers) { bool exists = false; for (int i = oguUsers.Length - 1; i >= 0; i--) { if (SynchronizeHelper.AppendNamingContext(SynchronizeHelper.GetOguObjectDN(oguUsers[i])) == memberDN.ToString()) { exists = true; break; } } if (exists == false) return true; } return false; }
protected override bool ComparePropertyValue(IOguObject srcOguObject, string srcPropertyName, ADObjectWrapper adObject, string targetPropertyName, string context) { string targetPropertyValue = null; if (adObject.Properties[targetPropertyName] != null) targetPropertyValue = adObject.Properties[targetPropertyName].ToString(); return SynchronizeHelper.AppendNamingContext(SynchronizeHelper.GetOguObjectDN(srcOguObject)) == targetPropertyValue; }
public override ObjectModifyType Compare(IOguObject srcObject, ADObjectWrapper targetObject) { ObjectModifyType result = CompareProperties(srcObject, targetObject); //if (IsChildrenModified(srcObject, targetObject)) // result |= ObjectModifyType.ChildrenModified; if (targetObject.Properties.Contains("displayNamePrintable") == false || SynchronizeHelper.PermissionCenterInvolved.Equals(targetObject.Properties["displayNamePrintable"]) == false) { result |= ObjectModifyType.MissingMarker; } return result; }
public static IOguObject Find(ADObjectWrapper childADObject, IEnumerable<IOguObject> oguObjects) { IOguObject result = null; //这里仅仅是查找所给集合里是不是存在相应的对象 foreach (var obj in oguObjects) { if (obj.ObjectType == SchemaType.Users) { if (((IUser)obj).IsSideline) { // continue; } } var guid = childADObject.NativeGuid; if (SynchronizeContext.Current.IDMapper.ADIDMappingDictionary.ContainsKey(guid)) //有映射 { if (obj.ID == SynchronizeContext.Current.IDMapper.ADIDMappingDictionary[guid].SCObjectID) { result = obj; } } else { switch (childADObject.ObjectType) { case ADSchemaType.Organizations: if (SynchronizeHelper.AppendNamingContext(childADObject.DN) == SynchronizeHelper.AppendNamingContext(SynchronizeHelper.GetOguObjectDN(obj))) { result = obj; } break; case ADSchemaType.Groups: case ADSchemaType.Users: if (childADObject.Properties["samAccountName"].ToString() == obj.Properties["LOGON_NAME"].ToString()) { result = obj; } break; } } } return result; }
public void PrepareAndAddModifiedItem(IOguObject oguObject, ADObjectWrapper adObject, ObjectModifyType objectModifyType) { ModifiedItem item = new ModifiedItem() { OguObjectData = oguObject, ADObjectData = adObject, ModifyType = objectModifyType }; if (oguObject.ObjectType == SchemaType.Groups) { this.ModifiedGroupItems.Add(item); } else { this.ModifiedOuAndUserItems.Add(item); } }
protected override bool ComparePropertyValue(IOguObject srcOguObject, string srcPropertyName, ADObjectWrapper adObject, string targetPropertyName, string context) { int userAccountControl = Convert.ToInt32(adObject.Properties[targetPropertyName]); ADS_USER_FLAG uacFlag = ADS_USER_FLAG.ADS_UF_NONE; bool result = true; if (Enum.TryParse(context, out uacFlag)) { bool originalFlag = ((userAccountControl & (int)uacFlag) == (int)uacFlag); result = originalFlag == (bool)srcOguObject.Properties[srcPropertyName]; } return result; }
protected override bool ComparePropertyValue(IOguObject srcOguObject, string srcPropertyName, ADObjectWrapper adObject, string targetPropertyName, string context) { string srcPropertyValue = null; if (srcOguObject.Properties[srcPropertyName] != null) srcPropertyValue = srcOguObject.Properties[srcPropertyName].ToString(); string targetPropertyValue = null; if (adObject.Properties[targetPropertyName] != null) targetPropertyValue = adObject.Properties[targetPropertyName].ToString(); bool result = false; if (srcPropertyValue != null && targetPropertyValue != null) result = srcPropertyValue == targetPropertyValue; return result; }
protected override bool ComparePropertyValue(OGUPermission.IOguObject srcOguObject, string srcPropertyName, ADObjectWrapper adObject, string targetPropertyName, string context) { if (srcOguObject.FullPath == SynchronizeContext.Current.SourceRootPath) { //名称以权限中心为准 return adObject.DN == SynchronizeHelper.AppendNamingContext(SynchronizeContext.Current.TargetRootOU); } else { string path = SynchronizeHelper.GetRelativePath(srcOguObject); if (path.IndexOf('\\') > 0) { return base.ComparePropertyValue(srcOguObject, srcPropertyName, adObject, targetPropertyName, context); } else { string dn = SynchronizeContext.Current.GetMappedName(srcOguObject.Name); return adObject.DN == SynchronizeHelper.AppendNamingContext(dn); } } }
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); } }
protected abstract bool ComparePropertyValue(IOguObject srcOguObject, string srcPropertyName, ADObjectWrapper adObject, string targetPropertyName, string context);
protected override bool ComparePropertyValue(IOguObject srcOguObject, string srcPropertyName, ADObjectWrapper adObject, string targetPropertyName, string context) { return base.ComparePropertyValue(srcOguObject, srcPropertyName, adObject, targetPropertyName, context); }
public static bool AreParentPathEqaul(IOguObject oguObject, ADObjectWrapper adObject) { var localPathToDN = SynchronizeHelper.AppendNamingContext(SynchronizeHelper.GetParentObjectDN(oguObject)); return localPathToDN == ADHelper.GetParentRdnSequence(adObject.DN); }
/// <summary> /// 判断AD对象的DN和ogu对象的Path是否相同,此处需要考虑转义的测试 /// </summary> /// <param stringValue="oguObject"></param> /// <param stringValue="adObject"></param> /// <returns></returns> public static bool ArePathEqaul(IOguObject oguObject, ADObjectWrapper adObject) { var localPathToDN = SynchronizeHelper.AppendNamingContext(SynchronizeHelper.GetOguObjectDN(oguObject)); return localPathToDN == adObject.DN; }
public static ObjectModifyType Compare(IOguObject oguObject, ADObjectWrapper adObject) { OguAndADObjectComparerBase comparer = GetComparer(oguObject); return comparer.Compare(oguObject, adObject); }