Browse Source

Minor logging improvement

Tal Aloni 7 years ago
parent
commit
46d5aa2982

+ 2 - 2
SMBLibrary/Server/SMB1/TreeConnectHelper.cs

@@ -53,7 +53,7 @@ namespace SMBLibrary.Server.SMB1
                 header.Status = NTStatus.STATUS_INSUFF_SERVER_RESOURCES;
                 return new ErrorResponse(request.CommandName);
             }
-            state.LogToServer(Severity.Information, "Tree Connect: User '{0}' connected to '{1}'", session.UserName, share.Name);
+            state.LogToServer(Severity.Information, "Tree Connect: User '{0}' connected to '{1}' (UID: {2}, TID: {3})", session.UserName, share.Name, header.UID, treeID.Value);
             header.TID = treeID.Value;
             if (isExtended)
             {
@@ -111,7 +111,7 @@ namespace SMBLibrary.Server.SMB1
         {
             SMB1Session session = state.GetSession(header.UID);
             session.DisconnectTree(header.TID);
-            state.LogToServer(Severity.Information, "Tree Disconnect: User '{0}' disconnected from '{1}'", session.UserName, share.Name);
+            state.LogToServer(Severity.Information, "Tree Disconnect: User '{0}' disconnected from '{1}' (UID: {2}, TID: {3})", session.UserName, share.Name, header.UID, header.TID);
             return new TreeDisconnectResponse();
         }
     }

+ 2 - 2
SMBLibrary/Server/SMB2/TreeConnectHelper.cs

@@ -50,7 +50,7 @@ namespace SMBLibrary.Server.SMB2
             {
                 return new ErrorResponse(request.CommandName, NTStatus.STATUS_INSUFF_SERVER_RESOURCES);
             }
-            state.LogToServer(Severity.Information, "Tree Connect: User '{0}' connected to '{1}'", session.UserName, share.Name);
+            state.LogToServer(Severity.Information, "Tree Connect: User '{0}' connected to '{1}' (SessionID: {2}, TreeID: {3})", session.UserName, share.Name, request.Header.SessionID, treeID.Value);
             response.Header.TreeID = treeID.Value;
             response.ShareType = shareType;
             response.ShareFlags = shareFlags;
@@ -81,7 +81,7 @@ namespace SMBLibrary.Server.SMB2
         {
             SMB2Session session = state.GetSession(request.Header.SessionID);
             session.DisconnectTree(request.Header.TreeID);
-            state.LogToServer(Severity.Information, "Tree Disconnect: User '{0}' disconnected from '{1}'", session.UserName, share.Name);
+            state.LogToServer(Severity.Information, "Tree Disconnect: User '{0}' disconnected from '{1}' (SessionID: {2}, TreeID: {3})", session.UserName, share.Name, request.Header.SessionID, request.Header.TreeID);
             return new TreeDisconnectResponse();
         }
     }

+ 2 - 1
SMBLibrary/Server/SMBServer.SMB1.cs

@@ -149,7 +149,7 @@ namespace SMBLibrary.Server
                 }
                 else if (command is LogoffAndXRequest)
                 {
-                    state.LogToServer(Severity.Information, "Logoff: User '{0}' logged off.", session.UserName);
+                    state.LogToServer(Severity.Information, "Logoff: User '{0}' logged off. (UID: {1})", session.UserName, header.UID);
                     m_securityProvider.DeleteSecurityContext(ref session.SecurityContext.AuthenticationContext);
                     state.RemoveSession(header.UID);
                     return new LogoffAndXResponse();
@@ -159,6 +159,7 @@ namespace SMBLibrary.Server
                     ISMBShare share = session.GetConnectedTree(header.TID);
                     if (share == null)
                     {
+                        state.LogToServer(Severity.Verbose, "{0} failed. Invalid TID (UID: {1}, TID: {2}).", command.CommandName, header.UID, header.TID);
                         header.Status = NTStatus.STATUS_SMB_BAD_TID;
                         return new ErrorResponse(command.CommandName);
                     }

+ 2 - 1
SMBLibrary/Server/SMBServer.SMB2.cs

@@ -108,7 +108,7 @@ namespace SMBLibrary.Server
                 }
                 else if (command is LogoffRequest)
                 {
-                    state.LogToServer(Severity.Information, "Logoff: User '{0}' logged off.", session.UserName);
+                    state.LogToServer(Severity.Information, "Logoff: User '{0}' logged off. (SessionID: {1})", session.UserName, command.Header.SessionID);
                     m_securityProvider.DeleteSecurityContext(ref session.SecurityContext.AuthenticationContext);
                     state.RemoveSession(command.Header.SessionID);
                     return new LogoffResponse();
@@ -126,6 +126,7 @@ namespace SMBLibrary.Server
                     ISMBShare share = session.GetConnectedTree(command.Header.TreeID);
                     if (share == null)
                     {
+                        state.LogToServer(Severity.Verbose, "{0} failed. Invalid TreeID (SessionID: {1}, TreeID: {2}).", command.CommandName, command.Header.SessionID, command.Header.TreeID);
                         return new ErrorResponse(command.CommandName, NTStatus.STATUS_NETWORK_NAME_DELETED);
                     }