Working on some of the fundamentals of the Context side of things. The Win 32 API is very wonky here though. Going to take some time.

This commit is contained in:
antiduh
2014-06-19 21:53:34 +00:00
parent 07b6c4c77c
commit cfba81cfe2
5 changed files with 132 additions and 0 deletions

52
Contexts/Context.cs Normal file
View File

@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NSspi
{
public class Context : IDisposable
{
private bool disposed;
public Context( Credential cred )
{
this.Credential = cred;
this.disposed = false;
}
~Context()
{
Dispose( false );
}
protected Credential Credential { get; private set; }
public long ContextHandle { get; protected set; }
public void Dispose()
{
Dispose( true );
GC.SuppressFinalize( this );
}
protected virtual void Dispose( bool disposing )
{
if( this.disposed ) { return; }
if( disposing )
{
this.Credential.Dispose();
}
long contextHandleCopy = this.ContextHandle;
NativeMethods.DeleteSecurityContext( ref contextHandleCopy );
this.ContextHandle = 0;
this.disposed = true;
}
}
}