예제 #1
0
        public Schema GetMmsSchema()
        {
            Schema schema = Schema.Create();

            foreach (AcmaSchemaObjectClass schemaObject in ActiveConfig.DB.ObjectClassesBindingList)
            {
                SchemaType schemaType = SchemaType.Create(schemaObject.Name, true);
                schemaType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute("objectId", AttributeType.String, AttributeOperation.ImportOnly));

                foreach (AcmaSchemaAttribute attribute in schemaObject.Attributes.Where(t => t.Name != "objectId"))
                {
                    if (attribute.Operation == AcmaAttributeOperation.AcmaInternal || attribute.Operation == AcmaAttributeOperation.AcmaInternalTemp)
                    {
                        continue;
                    }

                    if (attribute.IsMultivalued)
                    {
                        schemaType.Attributes.Add(SchemaAttribute.CreateMultiValuedAttribute(attribute.Name, attribute.MmsType, attribute.MmsOperationType));
                    }
                    else
                    {
                        schemaType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute(attribute.Name, attribute.MmsType, attribute.MmsOperationType));
                    }
                }

                schema.Types.Add(schemaType);
            }

            return(schema);
        }
        private static SchemaType GetSchemaTypeGroup(IOktaClient client)
        {
            SchemaType      mmsType      = SchemaType.Create("group", true);
            SchemaAttribute mmsAttribute = SchemaAttribute.CreateAnchorAttribute("id", AttributeType.String, AttributeOperation.ImportOnly);

            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("created", AttributeType.String, AttributeOperation.ImportOnly);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("lastUpdated", AttributeType.String, AttributeOperation.ImportOnly);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("lastMembershipUpdated", AttributeType.String, AttributeOperation.ImportOnly);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("type", AttributeType.String, AttributeOperation.ImportOnly);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("name", AttributeType.String, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("description", AttributeType.String, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateMultiValuedAttribute("member", AttributeType.Reference, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            return(mmsType);
        }
예제 #3
0
파일: CDATA.cs 프로젝트: fujie/apiserver
 // Get Schema
 public Schema GetSchema(KeyedCollection <string, ConfigParameter> _configParameters)
 {
     utils.Logger(TraceEventType.Information,
                  ConstDefinition.ID0100_START_GETSCHEMA,
                  ConstDefinition.MSG0100_START_GETSCHEMA);
     try
     {
         SchemaType personType = SchemaType.Create("Person", false);
         personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute("Username", AttributeType.String));
         personType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute("Alias", AttributeType.String));
         personType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute("Email", AttributeType.String));
         personType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute("LastName", AttributeType.String));
         personType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute("EmailEncodingKey", AttributeType.String));
         personType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute("LanguageLocaleKey", AttributeType.String));
         personType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute("LocaleSidKey", AttributeType.String));
         personType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute("ProfileId", AttributeType.String));
         personType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute("TimeZoneSidKey", AttributeType.String));
         personType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute("UserPermissionsOfflineUser", AttributeType.Boolean));
         personType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute("UserPermissionsMarketingUser", AttributeType.Boolean));
         Schema schema = Schema.Create();
         schema.Types.Add(personType);
         return(schema);
     }
     catch (Exception ex)
     {
         utils.Logger(TraceEventType.Error,
                      ConstDefinition.ID0199_ERROR_GETSCHEMA,
                      ConstDefinition.MSG0199_ERROR_GETSCHEMA + ex.Message);
         throw new ExtensibleExtensionException(ConstDefinition.MSG0199_ERROR_GETSCHEMA + ex.Message);
     }
 }
        private static SchemaType GetSchemaTypePublicChannel()
        {
            SchemaType mmsType = SchemaType.Create("publicChannel", true);

            SchemaAttribute mmsAttribute = SchemaAttribute.CreateAnchorAttribute("id", AttributeType.String, AttributeOperation.ImportOnly);

            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateAnchorAttribute("teamid", AttributeType.String, AttributeOperation.ImportOnly);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("description", AttributeType.String, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("displayName", AttributeType.String, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("email", AttributeType.String, AttributeOperation.ImportOnly);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("webUrl", AttributeType.String, AttributeOperation.ImportOnly);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("team", AttributeType.Reference, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("isFavoriteByDefault", AttributeType.Boolean, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            return(mmsType);
        }
        private static SchemaType GetCustomerType()
        {
            SchemaType customerType = SchemaType.Create("customer", false);

            customerType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute("objectID", AttributeType.String));
            customerType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute("companyName", AttributeType.String));
            customerType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute("domain", AttributeType.String));
            customerType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute("tenantId", AttributeType.String));

            return(customerType);
        }
        public Schema GetSchema(System.Collections.ObjectModel.KeyedCollection <string, ConfigParameter> configParameters)
        {
            Schema schema = Schema.Create();

            Microsoft.MetadirectoryServices.SchemaType type;

            //we want to fetch schema for all MAs, that way configuration wont get lost if an item is
            //unselected, and the checkbox can become simply an activate/deactivate switch
            DataSet mas = FIMConfiguration.GetManagementAgents(null);

            foreach (DataRow ma in mas.Tables["Config"].Rows)
            {
                string maName = ma["ma_name"].ToString();
                string maType = ma["ma_type"].ToString();
                string maList = ma["ma_listname"].ToString();

                if (maType.Equals("FIM", StringComparison.InvariantCultureIgnoreCase) ||
                    maList.Equals("Provisioning Management Agent (Insight)", StringComparison.InvariantCultureIgnoreCase))
                {
                    continue;
                }

                //create a new schema type based on the ma
                type = Microsoft.MetadirectoryServices.SchemaType.Create(maName, false);

                //add a generic Anchor Attribute to allow user to add flows for the actual anchor
                type.Attributes.Add(SchemaAttribute.CreateAnchorAttribute("Anchor", AttributeType.String));

                //we must preface each attribute with the MA name to make it unique across the schema allowing for
                //an attribute in two different MAs with different data types, etc.

                //our data will come back as XML data, we will need to parse it for what we need
                XmlDocument xmldoc = FIMConfiguration.GetConfigXML(maName, "ma_schema_xml");

                XmlNamespaceManager xmlnsManager = new XmlNamespaceManager(xmldoc.NameTable);
                xmlnsManager.AddNamespace("dsml", "http://www.dsml.org/DSML");
                xmlnsManager.AddNamespace("ms-dsml", "http://www.microsoft.com/MMS/DSML");

                XmlNodeList attributes = xmldoc.SelectNodes("//dsml:directory-schema/dsml:attribute-type", xmlnsManager);

                //add each attribute found to the schema
                foreach (XmlNode attrib in attributes)
                {
                    string oid = attrib.SelectSingleNode("./dsml:syntax", xmlnsManager).InnerText;
                    type.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute(maName + " - " + attrib.Attributes["id"].Value, FIMConfiguration.GetDataType(oid)));
                }

                schema.Types.Add(type);
            }

            return(schema);
        }
        private static SchemaType GetPersonType()
        {
            SchemaType personType = SchemaType.Create("user", false);

            personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute("objectID", AttributeType.String));
            personType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute("company", AttributeType.String));
            personType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute("displayName", AttributeType.String));
            personType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute("firstName", AttributeType.String));
            personType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute("lastName", AttributeType.String));
            personType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute("usageLocation", AttributeType.String));
            personType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute("userPrincipalName", AttributeType.String));

            return(personType);
        }
        private static SchemaType GetSchemaTypeUser(IOktaClient client)
        {
            SchemaType      mmsType      = SchemaType.Create("user", true);
            SchemaAttribute mmsAttribute = SchemaAttribute.CreateAnchorAttribute("id", AttributeType.String, AttributeOperation.ImportOnly);

            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("status", AttributeType.String);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("created", AttributeType.String, AttributeOperation.ImportOnly);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("activated", AttributeType.String, AttributeOperation.ImportOnly);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("statusChanged", AttributeType.String, AttributeOperation.ImportOnly);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("lastLogin", AttributeType.String, AttributeOperation.ImportOnly);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("lastUpdated", AttributeType.String, AttributeOperation.ImportOnly);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("passwordChanged", AttributeType.String, AttributeOperation.ImportOnly);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("provider.type", AttributeType.String, AttributeOperation.ImportOnly);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("provider.name", AttributeType.String, AttributeOperation.ImportOnly);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateMultiValuedAttribute("enrolledFactors", AttributeType.String, AttributeOperation.ImportOnly);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateMultiValuedAttribute("availableFactors", AttributeType.String, AttributeOperation.ImportOnly);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("suspended", AttributeType.Boolean, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            foreach (SchemaAttribute a in SchemaProvider.GetSchemaJson(client))
            {
                mmsType.Attributes.Add(a);
            }

            return(mmsType);
        }
 internal SchemaAttribute GetObject()
 {
     if (this.IsAnchor)
     {
         return(SchemaAttribute.CreateAnchorAttribute(this.Name, this.DataType, this.AllowedAttributeOperation));
     }
     else if (this.IsMultiValued)
     {
         return(SchemaAttribute.CreateMultiValuedAttribute(this.Name, this.DataType, this.AllowedAttributeOperation));
     }
     else
     {
         return(SchemaAttribute.CreateSingleValuedAttribute(this.Name, this.DataType, this.AllowedAttributeOperation));
     }
 }
        private static SchemaType GetSchemaTypeUser()
        {
            SchemaType      mmsType      = SchemaType.Create("user", true);
            SchemaAttribute mmsAttribute = SchemaAttribute.CreateAnchorAttribute("id", AttributeType.String, AttributeOperation.ImportOnly);

            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("onPremisesSamAccountName", AttributeType.String, AttributeOperation.ImportOnly);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("upn", AttributeType.String, AttributeOperation.ImportOnly);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("displayName", AttributeType.String, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            return(mmsType);
        }
 public IEnumerable <SchemaAttribute> GetSchemaAttributes()
 {
     if (this.IsAnchor)
     {
         yield return(SchemaAttribute.CreateAnchorAttribute(this.AttributeName, this.AttributeType, this.Operation));
     }
     else
     {
         if (this.IsMultivalued)
         {
             yield return(SchemaAttribute.CreateMultiValuedAttribute(this.AttributeName, this.AttributeType, this.Operation));
         }
         else
         {
             yield return(SchemaAttribute.CreateSingleValuedAttribute(this.AttributeName, this.AttributeType, this.Operation));
         }
     }
 }
예제 #12
0
        public Schema GetSchema(KeyedCollection <string, ConfigParameter> configParameters)
        {
            Microsoft.MetadirectoryServices.SchemaType personType = Microsoft.MetadirectoryServices.SchemaType.Create("Person", false);

            this.GetMAConfig(configParameters);


            string[] rsaAttributes = new string[10];
            rsaAttributes[0] = "First Name";
            rsaAttributes[1] = "Last Name";
            rsaAttributes[2] = "Middle Name";
            rsaAttributes[3] = "User ID";
            rsaAttributes[4] = "Manager Email Address";
            rsaAttributes[5] = "Identity Source";
            rsaAttributes[6] = "Security Domain";
            rsaAttributes[7] = "Lockout Status";
            rsaAttributes[8] = "Token Serial Number";
            rsaAttributes[9] = "Token GUID";


            foreach (string attribName in rsaAttributes)
            {
                if (attribName == "User ID")
                {
                    personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(attribName, AttributeType.String));
                }

                else if (attribName == "Token Serial Number" || attribName == "Token GUID")
                {
                    personType.Attributes.Add(SchemaAttribute.CreateMultiValuedAttribute(attribName, AttributeType.String));
                }

                else
                {
                    personType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute(attribName, AttributeType.String));
                }
            }

            Schema schema = Schema.Create();

            schema.Types.Add(personType);

            return(schema);
        }
예제 #13
0
        /// <summary>
        /// Gets the schema that applies to the objects in this management agent
        /// </summary>
        /// <param name="configParameters">The configuration parameters supplied to this management agent</param>
        /// <returns>The Schema defining objects and attributes applicable to this management agent</returns>
        Schema IMAExtensible2GetSchema.GetSchema(KeyedCollection <string, ConfigParameter> configParameters)
        {
            try
            {
                ManagementAgent.MAParameters = new MAParameters(configParameters);
                Logger.LogPath = ManagementAgent.MAParameters.LogPath;
                Logger.WriteSeparatorLine('*');
                Logger.WriteLine("Loading Schema");

                MAConfig.Load(ManagementAgent.MAParameters.MAConfigurationFilePath);

                Schema schema = Schema.Create();

                foreach (MASchemaObject schemaObject in MASchema.Objects)
                {
                    SchemaType schemaType = SchemaType.Create(schemaObject.ObjectClass, true);
                    schemaType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute("entry-dn", AttributeType.String, AttributeOperation.ImportOnly));

                    foreach (MASchemaAttribute attribute in schemaObject.Attributes)
                    {
                        if (attribute.IsMultiValued)
                        {
                            schemaType.Attributes.Add(SchemaAttribute.CreateMultiValuedAttribute(attribute.Name, attribute.Type, attribute.Operation));
                        }
                        else
                        {
                            schemaType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute(attribute.Name, attribute.Type, attribute.Operation));
                        }
                    }

                    schema.Types.Add(schemaType);
                }

                Logger.WriteLine("Schema loaded successfully");
                return(schema);
            }
            catch (Exception ex)
            {
                Logger.WriteException(ex);
                throw new ExtensibleExtensionException("The schema could not be loaded: " + ex.Message, ex);
            }
        }
예제 #14
0
        public Schema GetSchema(KeyedCollection <string, ConfigParameter> configParameters)
        {
            //TODO: Refactor object discover to a function
            Schema schema = Schema.Create();
            // person
            SchemaType personType = Microsoft.MetadirectoryServices.SchemaType.Create(CS_OBJECTTYPE_PERSON, false);

            PersonDiscoveryJsonTypes.Result personSchema = new PersonDiscoveryJsonTypes.Result();
            // movie
            SchemaType movieType = Microsoft.MetadirectoryServices.SchemaType.Create(CS_OBJECTTYPE_MOVIE, false);

            MovieDiscoveryJsonTypes.Result movieSchema = new MovieDiscoveryJsonTypes.Result();
            foreach (PropertyInfo item in personSchema)
            {
                if (item.Name.ToLower().Equals("id"))
                {
                    string itemName = string.Format("{0}_{1}", CS_OBJECTTYPE_PERSON, item.Name);
                    personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(itemName, AttributeType.String));
                }
                else if (item.PropertyType.IsArray)
                {
                    switch (item.Name.ToLower())
                    {
                    case "known_for":
                        personType.Attributes.Add(SchemaAttribute.CreateMultiValuedAttribute(item.Name, AttributeType.Reference));
                        break;

                    default:
                        personType.Attributes.Add(SchemaAttribute.CreateMultiValuedAttribute(item.Name, AttributeType.String));
                        break;
                    }
                }
                else if (item.Name.ToLower().Equals("item"))
                {
                }
                else
                {
                    personType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute(item.Name, AttributeType.String));
                }
            }

            foreach (PropertyInfo item in movieSchema)
            {
                if (item.Name.ToLower().Equals("id"))
                {
                    string itemName = string.Format("{0}_{1}", CS_OBJECTTYPE_MOVIE, item.Name);
                    movieType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(itemName, AttributeType.String));
                }
                else if (item.PropertyType.IsArray)
                {
                    switch (item.Name.ToLower())
                    {
                    default:
                        movieType.Attributes.Add(SchemaAttribute.CreateMultiValuedAttribute(item.Name, AttributeType.String));
                        break;
                    }
                }
                else if (item.Name.ToLower().Equals("item"))
                {
                }
                else
                {
                    movieType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute(item.Name, AttributeType.String));
                }
            }

            schema.Types.Add(personType);
            schema.Types.Add(movieType);
            return(schema);
        }
        public Schema GetSchema(KeyedCollection <string, ConfigParameter> configParameters)
        {
            Microsoft.MetadirectoryServices.SchemaType personType = Microsoft.MetadirectoryServices.SchemaType.Create("Person", false);

            //myname = configParameters["myname"].Value;

            string myattribute1 = "USERNAME";
            string myattribute2 = "PASSWORD";
            string myattribute3 = "EMPLOYEE_ID";
            string myattribute4 = "FIRST_NAME";
            string myattribute5 = "LAST_NAME";
            string myattribute6 = "EMAIL";
            string myattribute7 = "EMPLOYEE_STATUS";
            string myattribute8 = "ROLE_ASSIGNMENT";
            string myattribute9 = "WORKPHONE";

            if (myattribute1 == "USERNAME")
            {
                personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(myattribute1, AttributeType.String));
            }

            if (myattribute2 == "PASSWORD")
            {
                personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(myattribute2, AttributeType.String));
            }

            if (myattribute3 == "EMPLOYEE_ID")
            {
                personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(myattribute3, AttributeType.String));
            }

            if (myattribute4 == "FIRST_NAME")
            {
                personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(myattribute4, AttributeType.String));
            }

            if (myattribute5 == "LAST_NAME")
            {
                personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(myattribute5, AttributeType.String));
            }

            if (myattribute6 == "EMAIL")
            {
                personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(myattribute6, AttributeType.String));
            }

            if (myattribute7 == "EMPLOYEE_STATUS")
            {
                personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(myattribute7, AttributeType.String));
            }

            if (myattribute8 == "ROLE_ASSIGNMENT")
            {
                personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(myattribute8, AttributeType.String));
            }

            if (myattribute9 == "WORKPHONE")
            {
                personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(myattribute9, AttributeType.String));
            }

            Schema schema = Schema.Create();

            schema.Types.Add(personType);

            return(schema);
        }
예제 #16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="importRunStep"></param>
        /// <returns></returns>

        public Schema GetSchema(KeyedCollection <string, ConfigParameter> configParameters)
        {
            Microsoft.MetadirectoryServices.SchemaType personType = Microsoft.MetadirectoryServices.SchemaType.Create("Person", false);

            //myname = configParameters["myname"].Value;

            string myattribute1  = "title";
            string myattribute2  = "username";
            string myattribute3  = "email";
            string myattribute4  = "firstName";
            string myattribute5  = "lastName";
            string myattribute6  = "mobileNo";
            string myattribute7  = "verifiedMobileNo";
            string myattribute8  = "passportId";
            string myattribute9  = "emailVerified";
            string myattribute10 = "mobileNoVerified";
            string myattribute11 = "userStore";
            string myattribute12 = "password";
            string myattribute13 = "confirmPassword";
            string myattribute14 = "oldPassword";

            if (myattribute1 == "title")
            {
                personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(myattribute1, AttributeType.String));
            }

            if (myattribute2 == "username")
            {
                personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(myattribute2, AttributeType.String));
            }

            if (myattribute3 == "email")
            {
                personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(myattribute3, AttributeType.String));
            }

            if (myattribute4 == "firstName")
            {
                personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(myattribute4, AttributeType.String));
            }

            if (myattribute5 == "lastName")
            {
                personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(myattribute5, AttributeType.String));
            }

            if (myattribute6 == "mobileNo")
            {
                personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(myattribute6, AttributeType.String));
            }

            if (myattribute7 == "verifiedMobileNo")
            {
                personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(myattribute7, AttributeType.String));
            }

            if (myattribute8 == "passportId")
            {
                personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(myattribute8, AttributeType.String));
            }

            if (myattribute9 == "emailVerified")
            {
                personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(myattribute9, AttributeType.String));
            }

            if (myattribute10 == "mobileNoVerified")
            {
                personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(myattribute10, AttributeType.String));
            }

            if (myattribute11 == "userStore")
            {
                personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(myattribute11, AttributeType.String));
            }

            if (myattribute12 == "password")
            {
                personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(myattribute12, AttributeType.String));
            }

            if (myattribute13 == "confirmPassword")
            {
                personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(myattribute13, AttributeType.String));
            }

            if (myattribute14 == "oldPassword")
            {
                personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(myattribute14, AttributeType.String));
            }

            Schema schema = Schema.Create();

            schema.Types.Add(personType);

            return(schema);
        }
예제 #17
0
        public Schema GetSchemaDetached()
        {
            Tracer.Enter(nameof(GetSchemaDetached));
            Schema schema = Schema.Create();

            try
            {
                using (SqlMethods methods = new SqlMethods())
                {
                    methods.OpenConnection();
                    List <string> objectClasses = new List <string>();

                    Tracer.TraceInformation($"objectclass-type {Configuration.ObjectClassType}");
                    if (Configuration.ObjectClassType == ObjectClassType.Column)
                    {
                        objectClasses = methods.GetObjectClasses().ToList(); //since we are using yield, we need to call ToList() to get results
                    }
                    else
                    {
                        objectClasses.Add(Configuration.ObjectClass);
                    }

                    List <AttributeDefinition> sva = new List <AttributeDefinition>();
                    sva = methods.GetSchema(Configuration.TableNameSingle).ToList(); //since we are using yield, we need to call ToList() to get results

                    List <AttributeDefinition> mva = new List <AttributeDefinition>();
                    if (Configuration.HasMultivalueTable)
                    {
                        mva = methods.GetSchema(Configuration.TableNameMulti).ToList(); //since we are using yield, we need to call ToList() to get results
                    }

                    foreach (string obj in objectClasses)
                    {
                        Tracer.TraceInformation($"start-object-class {obj}");
                        SchemaType schemaObj = SchemaType.Create(obj, true);

                        ObjectClass objectClass = Configuration.Schema.ObjectClasses.FirstOrDefault(c => c.Name.Equals(obj));
                        Tracer.TraceInformation($"found-schemaxml-information-for {obj}");

                        // single-values
                        Tracer.TraceInformation("start-detect-single-value-attributes");
                        List <string> excludeSv = Configuration.ReservedColumnNames.ToList();
                        foreach (AttributeDefinition ad in sva)
                        {
                            AttributeType attrType = ad.AttributeType;
                            if (objectClass != null)
                            {
                                if (objectClass.Excludes.Exists(x => x.Name.Equals(ad.Name)))
                                {
                                    Tracer.TraceInformation($"skipping-excluded-attribute {ad.Name}");
                                    continue;
                                }
                                attrType = GetAttributeOverride(objectClass, ad, attrType);
                            }
                            if (ad.Name.Equals(Configuration.AnchorColumn))
                            {
                                Tracer.TraceInformation($"adding-anchor name: {ad.Name}, type: {attrType} [{ad.AttributeOperation}]");
                                schemaObj.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(ad.Name, attrType));
                                continue;
                            }
                            if (excludeSv.Contains(ad.Name))
                            {
                                Tracer.TraceInformation($"skipping-reserved-column {ad.Name}");
                                continue;
                            }
                            Tracer.TraceInformation($"add-singlevalue name: {ad.Name}, type: {attrType} [{ad.AttributeOperation}]");
                            schemaObj.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute(ad.Name, attrType, ad.AttributeOperation));
                        }
                        Tracer.TraceInformation("end-detect-single-value-attributes");

                        // multivalues
                        if (Configuration.HasMultivalueTable)
                        {
                            Tracer.TraceInformation("start-detect-multi-value-attributes");
                            foreach (AttributeDefinition ad in mva)
                            {
                                AttributeType attrType = ad.AttributeType;
                                if (objectClass != null)
                                {
                                    if (objectClass.Excludes.Exists(x => x.Name.Equals(ad.Name)))
                                    {
                                        Tracer.TraceInformation($"skipping-excluded-attribute {ad.Name}");
                                        continue;
                                    }
                                    attrType = GetAttributeOverride(objectClass, ad, attrType);
                                }
                                if (excludeSv.Contains(ad.Name))
                                {
                                    Tracer.TraceInformation($"skipping-reserved-column {ad.Name}");
                                    continue;
                                }
                                if (schemaObj.Attributes.Contains(ad.Name) || schemaObj.AnchorAttributes.Contains(ad.Name))
                                {
                                    Tracer.TraceInformation($"skipping-existing-column {ad.Name} (already defined in single-value-table)");
                                    continue;
                                }
                                Tracer.TraceInformation($"add-multivalue name: {ad.Name}, type: {attrType} [{ad.AttributeOperation}]");
                                schemaObj.Attributes.Add(SchemaAttribute.CreateMultiValuedAttribute(ad.Name, attrType, ad.AttributeOperation));
                            }
                            Tracer.TraceInformation("end-detect-multi-value-attributes");
                        }

                        schema.Types.Add(schemaObj);
                        Tracer.TraceInformation($"end-object-class {obj}");
                    }
                }
            }
            catch (Exception ex)
            {
                Tracer.TraceError(nameof(GetSchemaDetached), ex);
                throw;
            }
            finally
            {
                Tracer.Exit(nameof(GetSchemaDetached));
            }
            return(schema);
        }
예제 #18
0
        Schema IMAExtensible2GetSchema.GetSchema(KeyedCollection <string, ConfigParameter> configParameters)
        {
            Tracer.Enter("getschema");
            try
            {
                Schema schema = Schema.Create();
                InitializeConfigParameters(configParameters);

                OpenRunspace();
                Command cmd = new Command(Path.GetFullPath(SchemaScript));
                cmd.Parameters.Add(new CommandParameter("Username", Username));
                cmd.Parameters.Add(new CommandParameter("Password", Password));
                cmd.Parameters.Add(new CommandParameter("Credentials", GetSecureCredentials()));
                schemaResults = InvokePowerShellScript(cmd, null);
                CloseRunspace();

                if (schemaResults != null)
                {
                    foreach (PSObject obj in schemaResults)
                    {
                        string objectTypeName = null;
                        HashSet <AttributeDefinition> attrs = new HashSet <AttributeDefinition>();

                        foreach (PSPropertyInfo p in obj.Properties)
                        {
                            string[] elements = p.Name.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                            string   attrName = elements[0].Trim();
                            string   attrType = elements[1].Trim();

                            if (string.Equals(attrName, Constants.ControlValues.ObjectClass, StringComparison.OrdinalIgnoreCase))
                            {
                                objectTypeName = p.Value.ToString();
                                Tracer.TraceInformation("object-class '{0}'", objectTypeName);
                            }
                            else
                            {
                                AttributeDefinition ad = new AttributeDefinition();
                                ad.Name         = Regex.Replace(attrName, "^Anchor-", "", RegexOptions.IgnoreCase);
                                ad.IsAnchor     = p.Name.StartsWith("anchor-", StringComparison.OrdinalIgnoreCase);
                                ad.IsMultiValue = p.Name.EndsWith("[]", StringComparison.OrdinalIgnoreCase);
                                switch (attrType.Replace("[]", "").ToLower())
                                {
                                case "boolean":
                                    ad.Type = AttributeType.Boolean;
                                    break;

                                case "binary":
                                    ad.Type = AttributeType.Binary;
                                    break;

                                case "integer":
                                    ad.Type = AttributeType.Integer;
                                    break;

                                case "reference":
                                    ad.Type = AttributeType.Reference;
                                    break;

                                case "string":
                                    ad.Type = AttributeType.String;
                                    break;

                                default:
                                    ad.Type = AttributeType.String;
                                    break;
                                }
                                Tracer.TraceInformation("name '{0}', isanchor: {1}, ismultivalue: {2}, type: {3}", ad.Name, ad.IsAnchor, ad.IsMultiValue, ad.Type.ToString());
                                attrs.Add(ad);
                            }
                        }
                        if (string.IsNullOrEmpty(objectTypeName))
                        {
                            Tracer.TraceError("missing-object-class");
                            throw new Microsoft.MetadirectoryServices.NoSuchObjectTypeException();
                        }

                        SchemaType objectClass = SchemaType.Create(objectTypeName, true);
                        foreach (AttributeDefinition def in attrs)
                        {
                            if (def.IsAnchor)
                            {
                                objectClass.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(def.Name, def.Type));
                            }
                            else
                            {
                                if (def.IsMultiValue)
                                {
                                    objectClass.Attributes.Add(SchemaAttribute.CreateMultiValuedAttribute(def.Name, def.Type));
                                }
                                else
                                {
                                    objectClass.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute(def.Name, def.Type));
                                }
                            }
                        }
                        if (objectClass.AnchorAttributes.Count == 1)
                        {
                            schema.Types.Add(objectClass);
                        }
                        else
                        {
                            Tracer.TraceError("missing-anchor-definition-on-object");
                            throw new Microsoft.MetadirectoryServices.AttributeNotPresentException();
                        }
                    }
                }
                schemaResults.Clear();
                return(schema);
            }
            catch (Exception ex)
            {
                Tracer.TraceError("getschema", ex);
                throw;
            }
            finally
            {
                Tracer.Exit("getschema");
            }
        }
        private static SchemaType GetSchemaTypeTeam()
        {
            SchemaType mmsType = SchemaType.Create("team", true);

            //Group

            SchemaAttribute mmsAttribute = SchemaAttribute.CreateAnchorAttribute("id", AttributeType.String, AttributeOperation.ImportOnly);

            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("displayName", AttributeType.String, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("description", AttributeType.String, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("mailNickname", AttributeType.String, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("visibility", AttributeType.String, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            // Group member
            mmsAttribute = SchemaAttribute.CreateMultiValuedAttribute("member", AttributeType.Reference, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateMultiValuedAttribute("owner", AttributeType.Reference, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            // Teams

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("webUrl", AttributeType.String, AttributeOperation.ImportOnly);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("isArchived", AttributeType.Boolean, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("template", AttributeType.String, AttributeOperation.ExportOnly);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("memberSettings_allowCreateUpdateChannels", AttributeType.Boolean, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("memberSettings_allowDeleteChannels", AttributeType.Boolean, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("memberSettings_allowAddRemoveApps", AttributeType.Boolean, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("memberSettings_allowCreateUpdateRemoveTabs", AttributeType.Boolean, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("memberSettings_allowCreateUpdateRemoveConnectors", AttributeType.Boolean, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("guestSettings_allowCreateUpdateChannels", AttributeType.Boolean, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("guestSettings_allowDeleteChannels", AttributeType.Boolean, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("messagingSettings_allowUserEditMessages", AttributeType.Boolean, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("messagingSettings_allowUserDeleteMessages", AttributeType.Boolean, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("messagingSettings_allowOwnerDeleteMessages", AttributeType.Boolean, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("messagingSettings_allowTeamMentions", AttributeType.Boolean, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("messagingSettings_allowChannelMentions", AttributeType.Boolean, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("funSettings_allowGiphy", AttributeType.Boolean, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("funSettings_giphyContentRating", AttributeType.String, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("funSettings_allowStickersAndMemes", AttributeType.Boolean, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            mmsAttribute = SchemaAttribute.CreateSingleValuedAttribute("funSettings_allowCustomMemes", AttributeType.Boolean, AttributeOperation.ImportExport);
            mmsType.Attributes.Add(mmsAttribute);

            return(mmsType);
        }