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:
52
Contexts/Context.cs
Normal file
52
Contexts/Context.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user