Bläddra i källkod

Client: Throw Exception if attemping to logoff when the client is not connected

Tal Aloni 7 år sedan
förälder
incheckning
6a03cfd952
2 ändrade filer med 10 tillägg och 0 borttagningar
  1. 5 0
      SMBLibrary/Client/SMB1Client.cs
  2. 5 0
      SMBLibrary/Client/SMB2Client.cs

+ 5 - 0
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);
 

+ 5 - 0
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);