Example #1
0
        internal TokenGroup(MemoryMarshaler m)
        {
            SID_AND_ATTRIBUTES sa = (SID_AND_ATTRIBUTES)m.ParseStruct(typeof(SID_AND_ATTRIBUTES));

            _sid        = new Sid(sa.Sid);
            _attributes = (GroupAttributes)sa.Attributes;
        }
Example #2
0
 public void AddGroup(Sid sid, GroupAttributes attributes)
 {
     _sid_and_attrs.Add(new InternalSidAndAttributes()
     {
         sid = sid, attr = (uint)attributes
     });
 }
        private static void PopulateGroupList(ListView listView, IEnumerable <UserGroup> groups)
        {
            foreach (UserGroup group in groups)
            {
                GroupAttributes flags = group.Attributes & ~(GroupAttributes.EnabledByDefault);

                if ((flags & GroupAttributes.Integrity) == GroupAttributes.None)
                {
                    ListViewItem item = new ListViewItem(group.ToString());
                    item.SubItems.Add(flags.ToString());

                    if ((flags & GroupAttributes.Enabled) == GroupAttributes.Enabled)
                    {
                        item.BackColor = Color.LightGreen;
                    }
                    else if ((flags & GroupAttributes.UseForDenyOnly) == GroupAttributes.UseForDenyOnly)
                    {
                        item.BackColor = Color.LightSalmon;
                    }
                    item.Tag = group;
                    listView.Items.Add(item);
                }
            }
            listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }
Example #4
0
        /// <summary>
        /// Modify groups in the context.
        /// </summary>
        /// <param name="type">The type of group to modify.</param>
        /// <param name="groups">The list of SIDs to modify.</param>
        /// <param name="attributes">The attributes for the SIDs.</param>
        /// <param name="operation">The operation for the SIDs.</param>
        public void ModifyGroups(AuthZGroupSidType type, IEnumerable <Sid> groups, GroupAttributes attributes, AuthZSidOperation operation)
        {
            if (groups is null)
            {
                throw new ArgumentNullException(nameof(groups));
            }

            ModifyGroups(type, groups.Select(s => new UserGroup(s, attributes)), groups.Select(_ => operation));
        }
 /// <summary>
 /// Set the group attribute flags.
 /// </summary>
 /// <param name="attributes">The attributes to set.</param>
 /// <param name="throw_on_error">True to throw on error.</param>
 /// <returns>The NT status code.</returns>
 public NtStatus SetGroupAttributes(GroupAttributes attributes, bool throw_on_error)
 {
     using (var buffer = new GROUP_ATTRIBUTE_INFORMATION()
     {
         Attributes = attributes
     }.ToBuffer())
     {
         return(SecurityNativeMethods.SamSetInformationGroup(Handle,
                                                             GROUP_INFORMATION_CLASS.GroupAttributeInformation, buffer).ToNtException(throw_on_error));
     }
 }
        /// <summary>
        /// Walk through Unicode range database to build up property according to Group attribute
        /// </summary>
        public static bool BuildPropertyDataList(
            UnicodeRangeDatabase unicodeDb,
            UnicodeRange expectedRange,
            List <UnicodeRangeProperty> dataList,
            string name,
            GroupAttributes attribute)
        {
            bool isAdded = false;

            foreach (Group script in unicodeDb.Scripts)
            {
                string scriptAttrib = script.GroupName;
                if (attribute == GroupAttributes.Name)
                {
                    scriptAttrib = script.Name;
                }
                else if (attribute == GroupAttributes.Ids)
                {
                    scriptAttrib = script.Ids;
                }

                if (scriptAttrib.Equals(name, StringComparison.OrdinalIgnoreCase))
                {
                    UnicodeRange range = GetRange(script.UnicodeRange, expectedRange);
                    if (null != range)
                    {
                        dataList.Add(new UnicodeRangeProperty(TextUtil.UnicodeChartType.Script, script.Name, script.Ids, range));
                        isAdded = true;
                    }

                    if (null != script.SubGroups)
                    {
                        foreach (SubGroup subScript in script.SubGroups)
                        {
                            range = GetRange(subScript.UnicodeRange, expectedRange);
                            if (null != range)
                            {
                                dataList.Add(new UnicodeRangeProperty(
                                                 TextUtil.UnicodeChartType.Script,
                                                 subScript.SubGroupName,
                                                 subScript.SubIds,
                                                 range));
                                isAdded = true;
                            }
                        }
                    }
                }
            }

            foreach (Group symbol in unicodeDb.SymbolsAndPunctuation)
            {
                string symbolAttrib = symbol.GroupName;
                if (attribute == GroupAttributes.Name)
                {
                    symbolAttrib = symbol.Name;
                }
                else if (attribute == GroupAttributes.Ids)
                {
                    symbolAttrib = symbol.Ids;
                }

                if (symbolAttrib.Equals(name, StringComparison.OrdinalIgnoreCase))
                {
                    TextUtil.UnicodeChartType type = TextUtil.UnicodeChartType.Other;
                    if ((symbol.GroupName.ToLower(CultureInfo.InvariantCulture)).Contains("symbols") ||
                        (symbol.Name.ToLower(CultureInfo.InvariantCulture)).Contains("symbols"))
                    {
                        type = TextUtil.UnicodeChartType.Symbol;
                    }
                    else if ((symbol.GroupName.ToLower(CultureInfo.InvariantCulture)).Contains("punctuation") ||
                             (symbol.Name.ToLower(CultureInfo.InvariantCulture)).Contains("punctuation"))
                    {
                        type = TextUtil.UnicodeChartType.Punctuation;
                    }

                    UnicodeRange range = GetRange(symbol.UnicodeRange, expectedRange);
                    if (null != range)
                    {
                        dataList.Add(new UnicodeRangeProperty(type, symbol.Name, symbol.Ids, range));
                        isAdded = true;
                    }

                    if (null != symbol.SubGroups)
                    {
                        foreach (SubGroup subSymbol in symbol.SubGroups)
                        {
                            range = GetRange(subSymbol.UnicodeRange, expectedRange);
                            if (null != range)
                            {
                                dataList.Add(new UnicodeRangeProperty(type, subSymbol.SubGroupName, subSymbol.SubIds, range));
                                isAdded = true;
                            }
                        }
                    }
                }
            }
            return(isAdded);
        }
Example #7
0
 internal TokenGroup(MemoryMarshaler m)
 {
     SID_AND_ATTRIBUTES sa = (SID_AND_ATTRIBUTES)m.ParseStruct(typeof(SID_AND_ATTRIBUTES));
     _sid = new Sid(sa.Sid);
     _attributes = (GroupAttributes)sa.Attributes;
 }
 public void AddGroup(Sid sid, GroupAttributes attributes)
 {
     _sid_and_attrs.Add(new InternalSidAndAttributes(sid, attributes));
 }
 public InternalSidAndAttributes(Sid sid, GroupAttributes attributes)
 {
     _sid = sid;
     _attr = (uint)attributes;
 }
Example #10
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="sid">The SID</param>
 /// <param name="attributes">The attributes</param>
 public UserGroup(Sid sid, GroupAttributes attributes)
 {
     Sid        = sid;
     Attributes = attributes;
 }
Example #11
0
        void ReleaseDesignerOutlets()
        {
            if (UserClassName != null)
            {
                UserClassName.Dispose();
                UserClassName = null;
            }

            if (TxtPasswordClassName != null)
            {
                TxtPasswordClassName.Dispose();
                TxtPasswordClassName = null;
            }

            if (TxtDomainClassName != null)
            {
                TxtDomainClassName.Dispose();
                TxtDomainClassName = null;
            }

            if (TxtGroupClassName != null)
            {
                TxtGroupClassName.Dispose();
                TxtGroupClassName = null;
            }

            if (AttributeMapTableView != null)
            {
                AttributeMapTableView.Dispose();
                AttributeMapTableView = null;
            }

            if (BtnAddAttribute != null)
            {
                BtnAddAttribute.Dispose();
                BtnAddAttribute = null;
            }

            if (BtnAddDomainSchemaAttribute != null)
            {
                BtnAddDomainSchemaAttribute.Dispose();
                BtnAddDomainSchemaAttribute = null;
            }

            if (BtnAddGroupSchemaAttribute != null)
            {
                BtnAddGroupSchemaAttribute.Dispose();
                BtnAddGroupSchemaAttribute = null;
            }

            if (BtnAddPasswordSchemaAttribute != null)
            {
                BtnAddPasswordSchemaAttribute.Dispose();
                BtnAddPasswordSchemaAttribute = null;
            }

            if (BtnAddUserSchemaAttribute != null)
            {
                BtnAddUserSchemaAttribute.Dispose();
                BtnAddUserSchemaAttribute = null;
            }

            if (BtnApply != null)
            {
                BtnApply.Dispose();
                BtnApply = null;
            }

            if (BtnBaseDnForNestedGroups != null)
            {
                BtnBaseDnForNestedGroups.Dispose();
                BtnBaseDnForNestedGroups = null;
            }

            if (BtnClose != null)
            {
                BtnClose.Dispose();
                BtnClose = null;
            }

            if (BtnGroupSearch != null)
            {
                BtnGroupSearch.Dispose();
                BtnGroupSearch = null;
            }

            if (BtnMatchRuleInChain != null)
            {
                BtnMatchRuleInChain.Dispose();
                BtnMatchRuleInChain = null;
            }

            if (BtnRemoveAttribute != null)
            {
                BtnRemoveAttribute.Dispose();
                BtnRemoveAttribute = null;
            }

            if (BtnRemoveDomainSchemaAttribute != null)
            {
                BtnRemoveDomainSchemaAttribute.Dispose();
                BtnRemoveDomainSchemaAttribute = null;
            }

            if (BtnRemoveGroupSchemaAttribute != null)
            {
                BtnRemoveGroupSchemaAttribute.Dispose();
                BtnRemoveGroupSchemaAttribute = null;
            }

            if (BtnRemovePasswordSchemaAttribute != null)
            {
                BtnRemovePasswordSchemaAttribute.Dispose();
                BtnRemovePasswordSchemaAttribute = null;
            }

            if (BtnRemoveUserSchemaAttribute != null)
            {
                BtnRemoveUserSchemaAttribute.Dispose();
                BtnRemoveUserSchemaAttribute = null;
            }

            if (DomainAttributesTableView != null)
            {
                DomainAttributesTableView.Dispose();
                DomainAttributesTableView = null;
            }

            if (DomainList != null)
            {
                DomainList.Dispose();
                DomainList = null;
            }

            if (GroupAttributes != null)
            {
                GroupAttributes.Dispose();
                GroupAttributes = null;
            }

            if (GroupAttributesTableView != null)
            {
                GroupAttributesTableView.Dispose();
                GroupAttributesTableView = null;
            }

            if (PasswordAttributeList != null)
            {
                PasswordAttributeList.Dispose();
                PasswordAttributeList = null;
            }

            if (PasswordTableView != null)
            {
                PasswordTableView.Dispose();
                PasswordTableView = null;
            }

            if (TxtAttributeName != null)
            {
                TxtAttributeName.Dispose();
                TxtAttributeName = null;
            }

            if (TxtAttributeValue != null)
            {
                TxtAttributeValue.Dispose();
                TxtAttributeValue = null;
            }

            if (TxtDomainValue != null)
            {
                TxtDomainValue.Dispose();
                TxtDomainValue = null;
            }

            if (TxtGroupValue != null)
            {
                TxtGroupValue.Dispose();
                TxtGroupValue = null;
            }

            if (TxtPasswordValue != null)
            {
                TxtPasswordValue.Dispose();
                TxtPasswordValue = null;
            }

            if (TxtUserAttributeValue != null)
            {
                TxtUserAttributeValue.Dispose();
                TxtUserAttributeValue = null;
            }

            if (UsersAttributeList != null)
            {
                UsersAttributeList.Dispose();
                UsersAttributeList = null;
            }

            if (UsersMapTableView != null)
            {
                UsersMapTableView.Dispose();
                UsersMapTableView = null;
            }
        }
Example #12
0
 internal SamGroupMember(uint relative_id, uint attributes)
 {
     RelativeId = relative_id;
     Attributes = (GroupAttributes)attributes;
 }
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            this.BtnClose.Activated += (object sender, EventArgs e) => {
                this.Close();
                NSApplication.SharedApplication.StopModalWithCode(0);
            };


            // Attributes
            BtnAddAttribute.Activated += (object sender, EventArgs e) => {
                if (string.IsNullOrEmpty(TxtAttributeName.StringValue))
                {
                    UIErrorHelper.ShowAlert("Attribute name cannot be empty", "Alert");
                    return;
                }
                else if (string.IsNullOrEmpty(TxtAttributeValue.StringValue))
                {
                    UIErrorHelper.ShowAlert("Attribute value cannot be empty", "Alert");
                    return;
                }
                IdentityProviderDto.AttributesMap.Add(TxtAttributeName.StringValue, TxtAttributeValue.StringValue);
                ReloadTableView(AttributeMapTableView, IdentityProviderDto.AttributesMap);
                TxtAttributeName.StringValue  = (NSString)string.Empty;
                TxtAttributeValue.StringValue = (NSString)string.Empty;
            };

            BtnRemoveAttribute.Activated += (object sender, EventArgs e) => {
                if (AttributeMapTableView.SelectedRows.Count > 0)
                {
                    foreach (var index in AttributeMapTableView.SelectedRows)
                    {
                        var ds = (AttributeMapTableView.DataSource) as DictionaryDataSource;
                        if (ds != null)
                        {
                            var entry = ds.Entries[(int)index];
                            ds.Datasource.Remove(entry);
                            ds.Entries.RemoveAt((int)index);
                        }
                    }
                    ReloadTableView(AttributeMapTableView, IdentityProviderDto.AttributesMap);
                }
            };

            if (IdentityProviderDto.AttributesMap == null)
            {
                IdentityProviderDto.AttributesMap = new Dictionary <string, string> ();
            }

            if (IdentityProviderDto.Schema == null)
            {
                IdentityProviderDto.Schema = new Dictionary <string, SchemaObjectMappingDto> ();
            }

            ReloadTableView(AttributeMapTableView, IdentityProviderDto.AttributesMap);

            // User Schema
            BtnAddUserSchemaAttribute.Activated += (object sender, EventArgs e) => {
                if (string.IsNullOrEmpty(TxtUserAttributeValue.StringValue))
                {
                    UIErrorHelper.ShowAlert("User schema attribute name cannot be empty", "Alert");
                    return;
                }
                else if (((int)UsersAttributeList.SelectedIndex) < 0)
                {
                    UIErrorHelper.ShowAlert("User schema attribute value cannot be empty", "Alert");
                    return;
                }
                var key = ObjectId.ObjectIdUser.ToString();
                var ds  = (UsersMapTableView.DataSource) as DictionaryDataSource;
                if (ds != null && ds.Entries.Contains(UsersAttributeList.SelectedValue.ToString()))
                {
                    UIErrorHelper.ShowAlert("User schema attribute by this name already exists.", "Alert");
                    return;
                }
                IdentityProviderDto.Schema[key].AttributeMappings.Add(UsersAttributeList.SelectedValue.ToString(), TxtUserAttributeValue.StringValue);

                ReloadTableView(UsersMapTableView, IdentityProviderDto.Schema[key].AttributeMappings);
                TxtUserAttributeValue.StringValue = (NSString)string.Empty;
                UsersAttributeList.SelectItem((nint)(-1));
            };

            BtnRemoveUserSchemaAttribute.Activated += (object sender, EventArgs e) => {
                if (UsersMapTableView.SelectedRows.Count > 0)
                {
                    var ds    = (UsersMapTableView.DataSource) as DictionaryDataSource;
                    var index = UsersMapTableView.SelectedRows.First();
                    var entry = ds.Entries[(int)index];
                    var d     = ObjectId.ObjectIdUser.ToString();
                    IdentityProviderDto.Schema[d].AttributeMappings.Remove(entry);
                    ReloadTableView(UsersMapTableView, IdentityProviderDto.Schema[d].AttributeMappings);
                }
            };
            var desc = ObjectId.ObjectIdUser.ToString();

            if (!IdentityProviderDto.Schema.ContainsKey(desc))
            {
                IdentityProviderDto.Schema.Add(desc, new SchemaObjectMappingDto {
                    AttributeMappings = new Dictionary <string, string>()
                });
            }
            else
            {
                var attribMap = new Dictionary <string, string> ();
                foreach (var item in IdentityProviderDto.Schema[desc].AttributeMappings)
                {
                    UserAttributeId p;
                    if (Enum.TryParse(item.Key, out p))
                    {
                        attribMap.Add(p.GetDescription(), item.Value);
                    }
                }
                IdentityProviderDto.Schema[desc].AttributeMappings = attribMap;
            }
            ReloadTableView(UsersMapTableView, IdentityProviderDto.Schema[desc].AttributeMappings);

            // Password Schema
            BtnAddPasswordSchemaAttribute.Activated += (object sender, EventArgs e) => {
                if (string.IsNullOrEmpty(TxtPasswordValue.StringValue))
                {
                    UIErrorHelper.ShowAlert("Password schema attribute name cannot be empty", "Alert");
                    return;
                }
                else if (((int)PasswordAttributeList.SelectedIndex) < 0)
                {
                    UIErrorHelper.ShowAlert("Password schema attribute value cannot be empty", "Alert");
                    return;
                }
                var key = ObjectId.ObjectIdPasswordSettings.ToString();
                var ds  = (PasswordTableView.DataSource) as DictionaryDataSource;
                if (ds != null && ds.Entries.Contains(PasswordAttributeList.SelectedValue.ToString()))
                {
                    UIErrorHelper.ShowAlert("Password schema attribute by this name already exists.", "Alert");
                    return;
                }
                IdentityProviderDto.Schema[key].AttributeMappings.Add(PasswordAttributeList.SelectedValue.ToString(), TxtPasswordValue.StringValue);

                ReloadTableView(PasswordTableView, IdentityProviderDto.Schema[key].AttributeMappings);
                TxtPasswordValue.StringValue = (NSString)string.Empty;
                PasswordAttributeList.SelectItem((nint)(-1));
            };

            BtnRemovePasswordSchemaAttribute.Activated += (object sender, EventArgs e) => {
                if (PasswordTableView.SelectedRows.Count > 0)
                {
                    var ds    = (PasswordTableView.DataSource) as DictionaryDataSource;
                    var index = PasswordTableView.SelectedRows.First();
                    var entry = ds.Entries[(int)index];
                    var d     = ObjectId.ObjectIdPasswordSettings.ToString();
                    IdentityProviderDto.Schema[d].AttributeMappings.Remove(entry);
                    ReloadTableView(PasswordTableView, IdentityProviderDto.Schema[d].AttributeMappings);
                }
            };
            var desc1 = ObjectId.ObjectIdPasswordSettings.ToString();

            if (!IdentityProviderDto.Schema.ContainsKey(desc1))
            {
                IdentityProviderDto.Schema.Add(desc1, new SchemaObjectMappingDto {
                    AttributeMappings = new Dictionary <string, string> ()
                });
            }
            else
            {
                var attribMap = new Dictionary <string, string> ();
                foreach (var item in IdentityProviderDto.Schema[desc1].AttributeMappings)
                {
                    PasswordAttributeId p;
                    if (Enum.TryParse(item.Key, out p))
                    {
                        attribMap.Add(p.GetDescription(), item.Value);
                    }
                }
                IdentityProviderDto.Schema [desc1].AttributeMappings = attribMap;
            }
            ReloadTableView(PasswordTableView, IdentityProviderDto.Schema[desc1].AttributeMappings);


            // Group Schema
            BtnAddGroupSchemaAttribute.Activated += (object sender, EventArgs e) => {
                if (string.IsNullOrEmpty(TxtGroupValue.StringValue))
                {
                    UIErrorHelper.ShowAlert("Group schema attribute name cannot be empty", "Alert");
                    return;
                }
                else if (((int)GroupAttributes.SelectedIndex) < 0)
                {
                    UIErrorHelper.ShowAlert("Group schema attribute value cannot be empty", "Alert");
                    return;
                }
                var key = ObjectId.ObjectIdGroup.ToString();
                var ds  = (GroupAttributesTableView.DataSource) as DictionaryDataSource;
                if (ds != null && ds.Entries.Contains(GroupAttributes.SelectedValue.ToString()))
                {
                    UIErrorHelper.ShowAlert("Group schema attribute by this name already exists.", "Alert");
                    return;
                }
                IdentityProviderDto.Schema[key].AttributeMappings.Add(GroupAttributes.SelectedValue.ToString(), TxtGroupValue.StringValue);

                ReloadTableView(GroupAttributesTableView, IdentityProviderDto.Schema[key].AttributeMappings);
                TxtGroupValue.StringValue = (NSString)string.Empty;
                GroupAttributes.SelectItem((nint)(-1));
            };

            BtnRemoveGroupSchemaAttribute.Activated += (object sender, EventArgs e) => {
                if (GroupAttributesTableView.SelectedRows.Count > 0)
                {
                    var ds    = (GroupAttributesTableView.DataSource) as DictionaryDataSource;
                    var index = GroupAttributesTableView.SelectedRows.First();
                    var entry = ds.Entries[(int)index];
                    var d     = ObjectId.ObjectIdGroup.ToString();
                    IdentityProviderDto.Schema[d].AttributeMappings.Remove(entry);
                    ReloadTableView(GroupAttributesTableView, IdentityProviderDto.Schema[d].AttributeMappings);
                }
            };
            var desc2 = ObjectId.ObjectIdGroup.ToString();

            if (!IdentityProviderDto.Schema.ContainsKey(desc2))
            {
                IdentityProviderDto.Schema.Add(desc2, new SchemaObjectMappingDto {
                    AttributeMappings = new Dictionary <string, string>()
                });
            }
            else
            {
                var attribMap = new Dictionary <string, string> ();
                foreach (var item in IdentityProviderDto.Schema[desc2].AttributeMappings)
                {
                    GroupAttributeId p;
                    if (Enum.TryParse(item.Key, out p))
                    {
                        attribMap.Add(p.GetDescription(), item.Value);
                    }
                }
                IdentityProviderDto.Schema [desc2].AttributeMappings = attribMap;
            }
            ReloadTableView(GroupAttributesTableView, IdentityProviderDto.Schema[desc2].AttributeMappings);

            // Domain Schema
            BtnAddDomainSchemaAttribute.Activated += (object sender, EventArgs e) => {
                if (string.IsNullOrEmpty(TxtDomainValue.StringValue))
                {
                    UIErrorHelper.ShowAlert("Domain schema attribute name cannot be empty", "Alert");
                    return;
                }
                else if (((int)DomainList.SelectedIndex) < 0)
                {
                    UIErrorHelper.ShowAlert("Domain schema attribute value cannot be empty", "Alert");
                    return;
                }
                var key = ObjectId.ObjectIdDomain.ToString();
                var ds  = (DomainAttributesTableView.DataSource) as DictionaryDataSource;
                if (ds != null && ds.Entries.Contains(DomainList.SelectedValue.ToString()))
                {
                    UIErrorHelper.ShowAlert("Domain schema attribute by this name already exists.", "Alert");
                    return;
                }
                IdentityProviderDto.Schema[key].AttributeMappings.Add(DomainList.SelectedValue.ToString(), TxtDomainValue.StringValue);
                ReloadTableView(DomainAttributesTableView, IdentityProviderDto.Schema[key].AttributeMappings);
                TxtDomainValue.StringValue = (NSString)string.Empty;
                DomainList.SelectItem((nint)(-1));
            };

            BtnRemoveDomainSchemaAttribute.Activated += (object sender, EventArgs e) => {
                if (DomainAttributesTableView.SelectedRows.Count > 0)
                {
                    var ds    = (DomainAttributesTableView.DataSource) as DictionaryDataSource;
                    var index = DomainAttributesTableView.SelectedRows.First();
                    var entry = ds.Entries[(int)index];
                    var d     = ObjectId.ObjectIdDomain.ToString();
                    IdentityProviderDto.Schema[d].AttributeMappings.Remove(entry);
                    ReloadTableView(DomainAttributesTableView, IdentityProviderDto.Schema[d].AttributeMappings);
                }
            };
            var desc3 = ObjectId.ObjectIdDomain.ToString();

            if (!IdentityProviderDto.Schema.ContainsKey(desc3))
            {
                IdentityProviderDto.Schema.Add(desc3, new SchemaObjectMappingDto {
                    AttributeMappings = new Dictionary <string, string>()
                });
            }
            else
            {
                var attribMap = new Dictionary <string, string> ();
                foreach (var item in IdentityProviderDto.Schema[desc3].AttributeMappings)
                {
                    DomainAttributeId p;
                    if (Enum.TryParse(item.Key, out p))
                    {
                        attribMap.Add(p.GetDescription(), item.Value);
                    }
                }
                IdentityProviderDto.Schema [desc3].AttributeMappings = attribMap;
            }
            ReloadTableView(DomainAttributesTableView, IdentityProviderDto.Schema[desc3].AttributeMappings);

            this.BtnApply.Activated += (object sender, EventArgs e) => {
                if (IsValid())
                {
                    IdentityProviderDto.BaseDnForNestedGroupsEnabled = BtnBaseDnForNestedGroups.StringValue == "1";
                    IdentityProviderDto.DirectGroupsSearchEnabled    = BtnGroupSearch.StringValue == "1";
                    IdentityProviderDto.MatchingRuleInChainEnabled   = BtnMatchRuleInChain.StringValue == "1";

                    var user = ObjectId.ObjectIdUser.ToString();
                    var pass = ObjectId.ObjectIdPasswordSettings.ToString();
                    var grp  = ObjectId.ObjectIdGroup.ToString();
                    var dmn  = ObjectId.ObjectIdDomain.ToString();
                    IdentityProviderDto.Schema [user].ObjectClass = UserClassName.StringValue;
                    IdentityProviderDto.Schema[pass].ObjectClass  = TxtPasswordClassName.StringValue;
                    IdentityProviderDto.Schema[grp].ObjectClass   = TxtGroupClassName.StringValue;
                    IdentityProviderDto.Schema[dmn].ObjectClass   = TxtDomainClassName.StringValue;

                    var schema = new Dictionary <string, SchemaObjectMappingDto>();

                    if (IdentityProviderDto.Schema[user].AttributeMappings.Count > 0)
                    {
                        schema.Add(user, IdentityProviderDto.Schema[user]);
                    }
                    if (IdentityProviderDto.Schema[pass].AttributeMappings.Count > 0)
                    {
                        schema.Add(pass, IdentityProviderDto.Schema[pass]);
                    }
                    if (IdentityProviderDto.Schema[grp].AttributeMappings.Count > 0)
                    {
                        schema.Add(grp, IdentityProviderDto.Schema[grp]);
                    }
                    if (IdentityProviderDto.Schema[dmn].AttributeMappings.Count > 0)
                    {
                        schema.Add(dmn, IdentityProviderDto.Schema[dmn]);
                    }

                    IdentityProviderDto.Schema = new Dictionary <string, SchemaObjectMappingDto>(schema);

                    this.Close();
                    NSApplication.SharedApplication.StopModalWithCode(1);
                }
            };

            if (IdentityProviderDto.AttributesMap == null)
            {
                IdentityProviderDto.AttributesMap = new Dictionary <string, string>();
            }
            if (IdentityProviderDto.Schema == null)
            {
                IdentityProviderDto.Schema = new Dictionary <string, SchemaObjectMappingDto>();
            }
            DtoToView();
        }