public LdapObjectChangeBuilder AddModification(string attributeName, object value) { if (AllowedAttributes.TryGetValue(attributeName, out var attr)) { var mod = new LdapMod(attr, value); Mods.Add(mod); } else { SpecialMods.Add(attributeName, value); } return(this); }
private LdapMod NormalizeLdapMod(LdapMod ldapMod, object oldValue) { switch (ldapMod.AttributeInfo.Name) { case "userAccountControl": { if (ldapMod.Value is string str) { if (str.StartsWith("-")) { var current = (UserAccountControl)oldValue; str = str.Substring(1).Trim(); var uac = Enum <UserAccountControl> .Find(str); ldapMod.Value = current &= ~uac; } else if (str.StartsWith("+")) { var current = (UserAccountControl)oldValue; str = str.Substring(1).Trim(); var uac = Enum <UserAccountControl> .Find(str); ldapMod.Value = current |= uac; } else { ldapMod.Value = Enum <UserAccountControl> .Find(str.Trim()); } } return(ldapMod); } default: { ldapMod.Value = new AttributeValueConverter().TryConvert(ldapMod.AttributeInfo, ldapMod.Value); return(ldapMod); } } }