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); } }
public static extern uint QueryContextAttributes(ref SspiHandle inContextHandle, QueryContextAttributes attribute, out IntPtr names);
public static extern uint QueryContextAttributes(ref SspiHandle inContextHandle, QueryContextAttributes attribute, out SecurityPackageContextSizes sizes);
public static extern uint QueryContextAttributes(ref SspiHandle inContextHandle, QueryContextAttributes attribute, out IntPtr names);
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); } }