From 4bfe7d8bc9d31b4c79be537d022bec138afb1b2b Mon Sep 17 00:00:00 2001 From: antiduh Date: Fri, 11 Jul 2014 22:16:12 +0000 Subject: [PATCH] Added a lifetime check in the ServerContext.ImpersonateClient method. --- NSspi/Contexts/ServerContext.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/NSspi/Contexts/ServerContext.cs b/NSspi/Contexts/ServerContext.cs index 2ea1721..0513538 100644 --- a/NSspi/Contexts/ServerContext.cs +++ b/NSspi/Contexts/ServerContext.cs @@ -183,14 +183,20 @@ namespace NSspi.Contexts { throw new ObjectDisposedException( "ServerContext" ); } + else if( this.Initialized == false ) + { + throw new InvalidOperationException( + "The server context has not been completely initialized." + ); + } else if( impersonating ) { throw new InvalidOperationException( "Cannot impersonate again while already impersonating." ); } else if( this.SupportsImpersonate == false ) { - throw new InvalidOperationException( - "The ServerContext is using a security package that does not support impersonation." + throw new InvalidOperationException( + "The ServerContext is using a security package that does not support impersonation." ); }