示例#1
0
        private string GetAttribute(string key)
        {
            string description = null;

            ObjectId selectedObjectId;
            var      keyValue = (KeyValuePair)cbObjectId.SelectedItem;

            if (Enum.TryParse(keyValue.Key.ToString(), false, out selectedObjectId))
            {
                switch (selectedObjectId)
                {
                case ObjectId.ObjectIdUser:
                    var user = new UserAttributeId();
                    if (Enum.TryParse(key, true, out user))
                    {
                        description = user.GetDescription();
                    }
                    break;

                case ObjectId.ObjectIdPasswordSettings:
                    var pwd = new PasswordAttributeId();
                    if (Enum.TryParse(key, true, out pwd))
                    {
                        description = pwd.GetDescription();
                    }
                    break;

                case ObjectId.ObjectIdGroup:
                    var grp = new GroupAttributeId();
                    if (Enum.TryParse(key, true, out grp))
                    {
                        description = grp.GetDescription();
                    }
                    break;

                case ObjectId.ObjectIdDomain:
                    var dmn = new DomainAttributeId();
                    if (Enum.TryParse(key, true, out dmn))
                    {
                        description = dmn.GetDescription();
                    }
                    break;

                default:
                    break;
                }
            }
            return(description);
        }
示例#2
0
        private List <KeyValuePair> GetAttributesForObjectId()
        {
            ObjectId selectedObjectId;
            var      keyvalues = new List <KeyValuePair>();
            var      keyValue  = (KeyValuePair)cbObjectId.SelectedItem;

            if (Enum.TryParse(keyValue.Key.ToString(), false, out selectedObjectId))
            {
                switch (selectedObjectId)
                {
                case ObjectId.ObjectIdUser:
                    var user = new UserAttributeId();
                    keyvalues = user.ToKeyValueList();
                    break;

                case ObjectId.ObjectIdPasswordSettings:
                    var pwd = new PasswordAttributeId();
                    keyvalues = pwd.ToKeyValueList();
                    break;

                case ObjectId.ObjectIdGroup:
                    var grp = new GroupAttributeId();
                    keyvalues = grp.ToKeyValueList();
                    break;

                case ObjectId.ObjectIdDomain:
                    var dmn = new DomainAttributeId();
                    keyvalues = dmn.ToKeyValueList();
                    break;

                default:
                    break;
                }
            }
            return(keyvalues);
        }
示例#3
0
        private Dictionary <string, SchemaObjectMappingDto> GetSchema(Dictionary <string, SchemaObjectMappingDto> input)
        {
            var schema = new Dictionary <string, SchemaObjectMappingDto>();

            var user = ObjectId.ObjectIdUser.ToString();
            var pass = ObjectId.ObjectIdPasswordSettings.ToString();
            var grp  = ObjectId.ObjectIdGroup.ToString();
            var dmn  = ObjectId.ObjectIdDomain.ToString();

            if (input.ContainsKey(user) && input [user].AttributeMappings.Count > 0)
            {
                schema.Add(ObjectId.ObjectIdUser.ToString(), new SchemaObjectMappingDto {
                    ObjectClass       = input [user].ObjectClass,
                    AttributeMappings = new Dictionary <string, string> ()
                });

                UserAttributeId attributeEnum = UserAttributeId.UserAttributeAccountName;
                foreach (var attribute in input[user].AttributeMappings.Keys)
                {
                    var e = attributeEnum.GetByDescription(attribute);
                    schema [ObjectId.ObjectIdUser.ToString()].AttributeMappings.Add(e.ToString(), input [user].AttributeMappings [attribute]);
                }
            }

            if (input.ContainsKey(pass) && input [pass].AttributeMappings.Count > 0)
            {
                schema.Add(ObjectId.ObjectIdPasswordSettings.ToString(), new SchemaObjectMappingDto {
                    ObjectClass       = input [pass].ObjectClass,
                    AttributeMappings = new Dictionary <string, string> ()
                });

                PasswordAttributeId attributeEnum = PasswordAttributeId.PasswordSettingsAttributeMaximumPwdAge;
                foreach (var attribute in input[pass].AttributeMappings.Keys)
                {
                    var e = attributeEnum.GetByDescription(attribute);
                    schema [ObjectId.ObjectIdPasswordSettings.ToString()].AttributeMappings.Add(e.ToString(), input [pass].AttributeMappings [attribute]);
                }
            }

            if (input.ContainsKey(grp) && input [grp].AttributeMappings.Count > 0)
            {
                schema.Add(ObjectId.ObjectIdGroup.ToString(), new SchemaObjectMappingDto {
                    ObjectClass       = input [grp].ObjectClass,
                    AttributeMappings = new Dictionary <string, string> ()
                });

                GroupAttributeId attributeEnum = GroupAttributeId.GroupAttributeAccountName;
                foreach (var attribute in input[grp].AttributeMappings.Keys)
                {
                    var e = attributeEnum.GetByDescription(attribute);
                    schema [ObjectId.ObjectIdGroup.ToString()].AttributeMappings.Add(e.ToString(), input [grp].AttributeMappings [attribute]);
                }
            }
            if (input.ContainsKey(dmn) && input [dmn].AttributeMappings.Count > 0)
            {
                schema.Add(ObjectId.ObjectIdDomain.ToString(), new SchemaObjectMappingDto {
                    ObjectClass       = input [dmn].ObjectClass,
                    AttributeMappings = new Dictionary <string, string> ()
                });

                DomainAttributeId attributeEnum = DomainAttributeId.DomainAttributeMaxPwdAge;
                foreach (var attribute in input[dmn].AttributeMappings.Keys)
                {
                    var e = attributeEnum.GetByDescription(attribute);
                    schema [ObjectId.ObjectIdDomain.ToString()].AttributeMappings.Add(e.ToString(), input [dmn].AttributeMappings [attribute]);
                }
            }

            return(schema);
        }