protected override bool ReleaseHandle() { CSecurityStatus status = CCredentialNativeMethods.FreeCredentialsHandle( ref base.rawHandle ); base.ReleaseHandle(); return(status == CSecurityStatus.OK); }
private void Init(CCredentialUse use) { string packageName; CTimeStamp rawExpiry = new CTimeStamp(); CSecurityStatus status = CSecurityStatus.InternalError; // -- Package -- // Copy off for the call, since this.SecurityPackage is a property. packageName = this.SecurityPackage; this.Handle = new CSafeCredentialHandle(); // The finally clause is the actual constrained region. The VM pre-allocates any stack space, // performs any allocations it needs to prepare methods for execution, and postpones any // instances of the 'uncatchable' exceptions (ThreadAbort, StackOverflow, OutOfMemory). RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { status = CCredentialNativeMethods.AcquireCredentialsHandle( null, packageName, use, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, ref this.Handle.rawHandle, ref rawExpiry ); } if (status != CSecurityStatus.OK) { throw new CSSPIException("Failed to call AcquireCredentialHandle", status); } this.Expiry = rawExpiry.ToDateTime(); }