Ejemplo n.º 1
0
        static void enumColumnView(IEnumCERTVIEWROW dbRow, AdcsDbRow row)
        {
            IEnumCERTVIEWCOLUMN dbColumn = dbRow.EnumCertViewColumn();

            while (dbColumn.Next() != -1)
            {
                String colName = dbColumn.GetName();
                Object colVal  = dbColumn.GetValue(CertAdmConstants.CV_OUT_BASE64);
                switch (colName)
                {
                case "RequestID":
                case "ExtensionRequestId":
                case "AttributeRequestId":
                case "CRLRowId":
                    row.RowId = (Int32)colVal;
                    break;
                }
                row.Properties.Add(colName, colVal);
            }
            CryptographyUtils.ReleaseCom(dbColumn);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets ADCS database schema for specified table. Table name is speicifed in <see cref="ViewTable"/> property.
        /// </summary>
        /// <returns>An array of table columns and their schema details.</returns>
        public AdcsDbColumnSchema[] GetTableSchema()
        {
            CCertView schemaView            = new CCertView();
            List <AdcsDbColumnSchema> items = new List <AdcsDbColumnSchema>();

            schemaView.OpenConnection(ConfigString);
            schemaView.SetTable((Int32)table);
            IEnumCERTVIEWCOLUMN columns = schemaView.EnumCertViewColumn(0);

            while (columns.Next() != -1)
            {
                var column = new AdcsDbColumnSchema {
                    Name        = columns.GetName(),
                    DisplayName = columns.GetDisplayName(),
                    DataType    = (AdcsDbColumnDataType)columns.GetType(),
                    MaxLength   = columns.GetMaxLength(),
                    IsIndexed   = Convert.ToBoolean(columns.IsIndexed())
                };
                items.Add(column);
            }
            CryptographyUtils.ReleaseCom(columns, schemaView);
            return(items.ToArray());
        }
Ejemplo n.º 3
0
        public Schema[] GetSchema(TableList table = TableList.Request)
        {
            if (String.IsNullOrEmpty(Name))
            {
                throw new UninitializedObjectException();
            }
            if (!Ping())
            {
                ServerUnavailableException e = new ServerUnavailableException(DisplayName);
                e.Data.Add(nameof(e.Source), OfflineSource.DCOM);
                throw e;
            }
            CCertView CaView = new CCertView();

            try {
                List <Schema> items = new List <Schema>();
                CaView.OpenConnection(ConfigString);
                CaView.SetTable((Int32)table);
                IEnumCERTVIEWCOLUMN columns = CaView.EnumCertViewColumn(0);
                while (columns.Next() != -1)
                {
                    String       name        = columns.GetName();
                    String       displayname = columns.GetDisplayName();
                    DataTypeEnum dataType    = (DataTypeEnum)columns.GetType();
                    Int32        maxLength   = columns.GetMaxLength();
                    Boolean      isIndexed   = Convert.ToBoolean(columns.IsIndexed());
                    items.Add(new Schema(name, displayname, dataType, maxLength, isIndexed));
                }
                columns.Reset();
                CryptographyUtils.ReleaseCom(columns);
                return(items.ToArray());
            } catch (Exception e) {
                throw Error.ComExceptionHandler(e);
            } finally {
                CryptographyUtils.ReleaseCom(CaView);
            }
        }