Receiving an SMB2 LOGOFF Request

When the server receives a request with an SMB2 header with a Command value equal to SMB2 LOGOFF, message handling MUST proceed as follows.

The server MUST locate the session being logged off, as specified in section

The server MUST remove this session from the GlobalSessionTable and also from the Connection.SessionTable, and deregister the session by invoking the event specified in [MS-SRVS] section, providing Session.SessionGlobalId as input parameter. ServerStatistics.sts0_sopens MUST be decreased by 1. The server MUST close every Open in Session.OpenTable of the old session, where Open.IsDurable is FALSE and Open.IsResilient is FALSE, as specified in section For all opens in Session.OpenTable where Open.IsDurable is TRUE or Open.IsResilient is TRUE, the server MUST set Open.Session, Open.Connection, and Open.TreeConnect to NULL. Any tree connects in Session.TreeConnectTable of the old session MUST be deregistered by invoking the event specified in [MS-SRVS] section, providing the tuple <TreeConnect.Share.ServerName, TreeConnect.Share.Name> and TreeConnect.TreeGlobalId as input parameters, and each of them MUST be freed. For each deregistered TreeConnect, TreeConnect.Share.CurrentUses MUST be decreased by 1.

If Connection.Dialect belongs to the SMB 3.x dialect family, the server MUST remove the session from each Channel.Connection.SessionTable in Session.ChannelList. All channels in Session.ChannelList MUST be removed and freed.

The server MUST construct an SMB2 LOGOFF Response with a status code of STATUS_SUCCESS, following the syntax specified in section 2.2.8, and send it to the client. The session itself is then freed.

The status code returned by this operation MUST be one of those defined in [MS-ERREF]. Common status codes returned by this operation include: