diff --git a/SMBLibrary/Client/SMB1Client.cs b/SMBLibrary/Client/SMB1Client.cs index 01b34c5..12ceffd 100644 --- a/SMBLibrary/Client/SMB1Client.cs +++ b/SMBLibrary/Client/SMB1Client.cs @@ -236,6 +236,11 @@ namespace SMBLibrary.Client public NTStatus Logoff() { + if (!m_isConnected) + { + throw new InvalidOperationException("A login session must be successfully established before attempting logoff"); + } + LogoffAndXRequest request = new LogoffAndXRequest(); TrySendMessage(request); diff --git a/SMBLibrary/Client/SMB2Client.cs b/SMBLibrary/Client/SMB2Client.cs index 0031408..9fc83df 100644 --- a/SMBLibrary/Client/SMB2Client.cs +++ b/SMBLibrary/Client/SMB2Client.cs @@ -162,6 +162,11 @@ namespace SMBLibrary.Client public NTStatus Logoff() { + if (!m_isConnected) + { + throw new InvalidOperationException("A login session must be successfully established before attempting logoff"); + } + LogoffRequest request = new LogoffRequest(); TrySendCommand(request);