コード例 #1
0
        private object GetData(string path, uint type)
        {
            uint currentBufferSize = this.currentBufferSize;

            this.record.dwMDAttributes = 1;
            this.record.dwMDUserType   = 1;
            this.record.dwMDDataType   = 0;
            this.record.dwMDIdentifier = type;
            this.record.pbMDData       = this.bufferHandle.DangerousGetHandle();
            this.record.dwMDDataLen    = this.currentBufferSize;
            uint num2 = adminBase.GetData((uint)this.mdHandle, path, ref this.record, ref currentBufferSize);

            switch (num2)
            {
            case 0x8007007a:
                this.EnsureRecordBuffer(currentBufferSize);
                num2 = adminBase.GetData((uint)this.mdHandle, path, ref this.record, ref currentBufferSize);
                break;

            case 0x80070003:
            case 0x800cc801:
                return(null);
            }
            if (num2 != 0)
            {
                throw FxTrace.Exception.AsError(new COMException(System.ServiceModel.Activation.SR.Hosting_MetabaseAccessError, (int)num2));
            }
            return(this.ConvertData());
        }
コード例 #2
0
        object GetData(string path, uint type)
        {
            uint bytes = currentBufferSize;

            record.dwMDAttributes = MSAdminBase.METADATA_INHERIT;
            record.dwMDUserType   = MSAdminBase.IIS_MD_UT_SERVER;
            record.dwMDDataType   = MSAdminBase.ALL_METADATA;
            record.dwMDIdentifier = type;
            record.pbMDData       = bufferHandle.DangerousGetHandle();
            record.dwMDDataLen    = currentBufferSize;

            uint hResult = adminBase.GetData((uint)mdHandle, path, ref record, ref bytes);

            if (hResult == E_INSUFFICIENT_BUFFER)
            {
                EnsureRecordBuffer(bytes);
                hResult = adminBase.GetData((uint)mdHandle, path, ref record, ref bytes);
            }

            if (hResult == E_PATH_NOT_FOUND || hResult == E_DATA_NOT_FOUND)
            {
                return(null);
            }
            else if (hResult != 0)
            {
                throw FxTrace.Exception.AsError(new COMException(SR.Hosting_MetabaseAccessError, (int)hResult));
            }

            return(ConvertData());
        }
コード例 #3
0
        private static int GetFlags(IMSAdminBase iisAdmin, string metabasePath, out OwaIsapiFilter.FormsAuthPropertyFlags flags)
        {
            flags = OwaIsapiFilter.FormsAuthPropertyFlags.None;
            int            result         = 0;
            MetadataRecord metadataRecord = OwaIsapiFilter.CreateFormsRecord(MBAttributes.None);

            using (metadataRecord)
            {
                int num;
                result = iisAdmin.GetData(SafeMetadataHandle.MetadataMasterRootHandle, metabasePath, metadataRecord, out num);
                flags  = (OwaIsapiFilter.FormsAuthPropertyFlags)Marshal.ReadInt32(metadataRecord.DataBuf.DangerousGetHandle());
            }
            return(result);
        }
コード例 #4
0
        private static bool CheckPermission(IMSAdminBase iisAdmin)
        {
            MetadataRecord metadataRecord = new MetadataRecord(0);
            bool           result;

            using (metadataRecord)
            {
                metadataRecord.Identifier = MBIdentifier.KeyType;
                metadataRecord.Attributes = MBAttributes.None;
                metadataRecord.UserType   = MBUserType.Server;
                metadataRecord.DataType   = MBDataType.String;
                SafeMetadataHandle key = new SafeMetadataHandle(IntPtr.Zero, null);
                int num;
                int data = iisAdmin.GetData(key, IMSAdminBaseHelper.W3SVC, metadataRecord, out num);
                result = (data != -2147024891);
            }
            return(result);
        }
コード例 #5
0
        /**
         * Returns null if there is no data for the ID.
         */
        public static Dictionary <DataField, String> GetData(String keyPath, UInt32 dataId)
        {
            METADATA_RECORD record = new METADATA_RECORD();

            record.dwMDIdentifier = dataId;
            record.dwMDAttributes = (UInt32)METADATA_ATTRIBUTES.METADATA_INHERIT;
            record.dwMDUserType   = (UInt32)METADATA_USER_TYPE.IIS_MD_UT_SERVER;
            record.dwMDDataType   = (UInt32)METADATA_TYPES.ALL_METADATA;
            try {
                uint len = 0;
                try {
                    baseInterface.GetData(METADATA_MASTER_ROOT_HANDLE, keyPath, ref record, out len);
                } catch (COMException e) {
                    switch ((UInt32)e.ErrorCode)
                    {
                    case 0x8007007A:   // HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)
                        bool retrieved = false;
                        while (!retrieved)
                        {
                            try {
                                if (len == 0)
                                {
                                    len = 1024;
                                }
                                else
                                {
                                    len = 2 * len;
                                }
                                record.pbMDData = Marshal.AllocCoTaskMem((int)len);
                                if (record.pbMDData == IntPtr.Zero)
                                {
                                    throw new ExternalException("Unable to allocate memory for Metabase data buffer.");
                                }
                                record.dwMDDataLen = (UInt32)len;
                                baseInterface.GetData(METADATA_MASTER_ROOT_HANDLE, keyPath, ref record, out len);
                                retrieved = true;
                            } catch (COMException e2) {
                                if ((UInt32)e2.ErrorCode == 0x8007007A)
                                {
                                    Marshal.FreeCoTaskMem(record.pbMDData);
                                }
                                else
                                {
                                    throw e2;
                                }
                            }
                        }
                        return(ToData(record));

                    case 0x800CC801:   // MD_ERROR_DATA_NOT_FOUND
                        break;

                    default:
                        throw e;
                    }
                } catch (DirectoryNotFoundException) {
                    // HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)
                }
                return(null);
            } finally {
                if (record.pbMDData != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(record.pbMDData);
                }
            }
        }