private void QueryContextString(QueryContextAttributes attribute, out string names)
        {
            if (attribute != QueryContextAttributes.Names && attribute != QueryContextAttributes.Authority)
            {
                throw new InvalidOperationException("Only names and authorities are strings");
            }

            var contextAddRefSuccess = false;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                DangerousAddRef(ref contextAddRefSuccess);
            }
            catch (Exception ex)
            {
                if (contextAddRefSuccess)
                {
                    DangerousRelease();
                    contextAddRefSuccess = false;
                }

                if (!(ex is ObjectDisposedException))
                {
                    throw;
                }
            }
            finally
            {
                var ptr    = new IntPtr();
                var result = NativeMethods.QueryContextAttributes(ref _handle, attribute, out ptr);

                DangerousRelease();

                if (result != NativeMethods.SEC_E_OK)
                {
                    throw Win32Exception.Create(result, "Unable to get the query context attribute names.");
                }

                names = Marshal.PtrToStringAuto(ptr);
            }
        }
Exemplo n.º 2
0
 public static extern uint QueryContextAttributes(ref SspiHandle inContextHandle, QueryContextAttributes attribute, out IntPtr names);
Exemplo n.º 3
0
 public static extern uint QueryContextAttributes(ref SspiHandle inContextHandle, QueryContextAttributes attribute, out SecurityPackageContextSizes sizes);
Exemplo n.º 4
0
 public static extern uint QueryContextAttributes(ref SspiHandle inContextHandle, QueryContextAttributes attribute, out IntPtr names);
Exemplo n.º 5
0
 public static extern uint QueryContextAttributes(ref SspiHandle inContextHandle, QueryContextAttributes attribute, out SecurityPackageContextSizes sizes);
        private void QueryContextString(QueryContextAttributes attribute, out string names)
        {
            if (attribute != QueryContextAttributes.Names && attribute != QueryContextAttributes.Authority)
                throw new InvalidOperationException("Only names and authorities are strings");

            var contextAddRefSuccess = false;
            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                DangerousAddRef(ref contextAddRefSuccess);
            }
            catch (Exception ex)
            {
                if (contextAddRefSuccess)
                {
                    DangerousRelease();
                    contextAddRefSuccess = false;
                }

                if (!(ex is ObjectDisposedException))
                    throw;
            }
            finally
            {
                var ptr = new IntPtr();
                var result = NativeMethods.QueryContextAttributes(ref _handle, attribute, out ptr);

                DangerousRelease();

                if (result != NativeMethods.SEC_E_OK)
                    throw Win32Exception.Create(result, "Unable to get the query context attribute names.");

                names = Marshal.PtrToStringAuto(ptr);
            }
        }