Ejemplo n.º 1
0
        private static bool IsFbaEnabled(string server, string localMetabasePath)
        {
            IMSAdminBase iisAdmin     = IMSAdminBaseHelper.Create(server);
            string       metabasePath = "/LM" + localMetabasePath;

            OwaIsapiFilter.FormsAuthPropertyFlags formsAuthPropertyFlags;
            int flags = OwaIsapiFilter.GetFlags(iisAdmin, metabasePath, out formsAuthPropertyFlags);

            if (flags == -2146646015)
            {
                return(false);
            }
            if (flags == -2147024891)
            {
                throw new OwaIsapiFilterException(Strings.FormsAuthenticationIsEnabledAccessDeniedException(metabasePath, 45054), flags);
            }
            if (flags == -2147024893)
            {
                throw new OwaIsapiFilterException(Strings.FormsAuthenticationIsEnabledPathNotFoundException(metabasePath, 45054), flags);
            }
            if (flags < 0)
            {
                throw new OwaIsapiFilterException(Strings.FormsAuthenticationIsEnabledUnknownErrorException(metabasePath, 45054), flags);
            }
            return((formsAuthPropertyFlags & OwaIsapiFilter.FormsAuthPropertyFlags.FbaEnabled) != OwaIsapiFilter.FormsAuthPropertyFlags.None);
        }
Ejemplo n.º 2
0
        private static void SetFlags(string server, string path, OwaIsapiFilter.FormsAuthPropertyFlags flags)
        {
            IMSAdminBase       imsadminBase = IMSAdminBaseHelper.Create(server);
            string             text         = "/LM" + path;
            SafeMetadataHandle safeMetadataHandle;
            int num = IMSAdminBaseHelper.OpenKey(imsadminBase, SafeMetadataHandle.MetadataMasterRootHandle, text, MBKeyAccess.Write, 15000, out safeMetadataHandle);

            using (safeMetadataHandle)
            {
                if (num == -2147024748)
                {
                    throw new FormsAuthenticationErrorPathBusyException(text);
                }
                if (num == -2147024893)
                {
                    throw new FormsAuthenticationMarkPathErrorPathNotFoundException(text);
                }
                if (num < 0)
                {
                    throw new OwaIsapiFilterException(Strings.FormsAuthenticationMarkPathErrorUnknownOpenError(text), num);
                }
                MetadataRecord metadataRecord = OwaIsapiFilter.CreateFormsRecord(MBAttributes.Inherit);
                using (metadataRecord)
                {
                    Marshal.WriteInt32(metadataRecord.DataBuf.DangerousGetHandle(), (int)flags);
                    num = imsadminBase.SetData(safeMetadataHandle, string.Empty, metadataRecord);
                }
                if (num == -2147024891)
                {
                    throw new FormsAuthenticationMarkPathAccessDeniedException(text, 45054);
                }
                if (num == -2147024888)
                {
                    throw new OutOfMemoryException();
                }
                if (num == -2147024893)
                {
                    throw new FormsAuthenticationMarkPathErrorPathNotFoundException(text);
                }
                if (num == -2146646008)
                {
                    throw new FormsAuthenticationMarkPathCannotMarkSecureAttributeException(text, 45054);
                }
                if (num < 0)
                {
                    throw new FormsAuthenticationMarkPathUnknownSetError(text, 45054, num);
                }
            }
            num = IisUtility.CommitMetabaseChanges(server);
            if (num < 0)
            {
                throw new OwaIsapiFilterException(Strings.CommitMetabaseChangesException(server), num);
            }
        }
Ejemplo n.º 3
0
        private static int GetMarkedPathCount(string server, string webSitePath)
        {
            int          num      = 0;
            IMSAdminBase iisAdmin = IMSAdminBaseHelper.Create(server);

            webSitePath = "/LM" + webSitePath;
            List <string> list = new List <string>();
            int           num2 = IMSAdminBaseHelper.GetDataPaths(iisAdmin, webSitePath, MBIdentifier.FormsAuthenticationEnabledProperty, MBDataType.Dword, ref list);

            if (num2 == -2147024893)
            {
                throw new OwaIsapiFilterException(Strings.FormsAuthenticationDeleteMarksIfUnusedPathNotFoundException(webSitePath), num2);
            }
            if (num2 < 0)
            {
                throw new OwaIsapiFilterException(Strings.FormsAuthenticationDeleteMarksIfUnusedUnknownErrorException(webSitePath, 45054), num2);
            }
            int[] array = new int[list.Count];
            for (int i = 0; i < list.Count; i++)
            {
                OwaIsapiFilter.FormsAuthPropertyFlags formsAuthPropertyFlags;
                num2 = OwaIsapiFilter.GetFlags(iisAdmin, list[i], out formsAuthPropertyFlags);
                if (num2 == -2147024891)
                {
                    throw new OwaIsapiFilterException(Strings.FormsAuthenticationDeleteMarksIfUnusedCheckMarkAccessDeniedException(list[i]), num2);
                }
                if (num2 != -2147024893 && num2 != -2146646015)
                {
                    if (num2 < 0)
                    {
                        throw new OwaIsapiFilterException(Strings.FormsAuthenticationDeleteMarksIfUnusedUnknownCheckErrorException(list[i]), num2);
                    }
                    num++;
                }
            }
            if (num == 1 && string.Compare(list[array[0]], webSitePath, true, CultureInfo.InvariantCulture) == 0)
            {
                num = 0;
            }
            return(num);
        }
Ejemplo n.º 4
0
        internal static IMSAdminBase Create(string server)
        {
            if (server == null)
            {
                MSAdminBase msadminBase = new MSAdminBase();
                return((IMSAdminBase)msadminBase);
            }
            Type         typeFromCLSID = Type.GetTypeFromCLSID(IMSAdminBaseHelper.MSAdminBaseGuid, server, false);
            IMSAdminBase imsadminBase  = (IMSAdminBase)Activator.CreateInstance(typeFromCLSID);

            if (IMSAdminBaseHelper.CheckPermission(imsadminBase))
            {
                return(imsadminBase);
            }
            object obj = null;

            if (COMHelper.Create(IMSAdminBaseHelper.MSAdminBaseGuid, IMSAdminBaseHelper.IIMSAdminBaseGuid, server, ref obj) == 0U)
            {
                return((IMSAdminBase)obj);
            }
            return(imsadminBase);
        }
Ejemplo n.º 5
0
        internal static int GetDataPaths(string searchPath, MBIdentifier propertyID, MBDataType dataType, ref List <string> paths)
        {
            IMSAdminBase iisAdmin = IMSAdminBaseHelper.Create();

            return(IMSAdminBaseHelper.GetDataPaths(iisAdmin, searchPath, propertyID, dataType, ref paths));
        }
Ejemplo n.º 6
0
 internal static IMSAdminBase Create()
 {
     return(IMSAdminBaseHelper.Create(null));
 }