/// <summary>
        /// create sasl bind response packet.
        /// </summary>
        /// <param name="context">
        /// an AdtsLdapContext object that indicates the context of LDAP.
        /// </param>
        /// <param name="securityContext">
        /// a ServerSecurityContext object that specifies the security provider.
        /// </param>
        /// <param name="enableMessageSecurity">
        /// a bool value that indicates whether enable message security.
        /// </param>
        /// <returns>
        /// a BindResponsePacket object that responses the SASL bind request.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// thrown when context is null.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// thrown when securityContext is null.
        /// </exception>
        public AdtsBindResponsePacket CreateSaslBindResponse(
            AdtsLdapContext context, ServerSecurityContext securityContext, bool enableMessageSecurity)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (securityContext == null)
            {
                throw new ArgumentNullException("securityContext");
            }

            if (context.Security == null)
            {
                context.Security = new AdtsLdapSaslSecurityLayer(securityContext);
                context.UsingMessageSecurity = enableMessageSecurity;
            }

            ResultCode resultCode = ResultCode.Success;

            if (securityContext.NeedContinueProcessing)
            {
                resultCode = ResultCode.SaslBindInProgress;
            }

            return this.CreateBindResponse(
                context, resultCode,
                string.Empty, string.Empty, null, securityContext.Token);
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="connection">The SMB connection associated with this session.</param>
 /// <param name="sessionId">Session Id of the Session</param>
 /// <param name="securityContext">The security context of the user that established the session, as obtained
 /// from the authentication subsystem after successful authentication.</param>
 /// <param name="creationTime">The time that the session was established.</param>
 /// <param name="idleTime">The time that the session processed its most recent request.</param>
 /// <param name="userName">The name of the user who established the session.</param>
 /// <param name="sessionGlobalId">A numeric 32-bit value obtained by registration with the Server Service Remote
 /// Protocol.</param>
 public CifsServerPerSession(
     IFileServiceServerConnection connection,
     long sessionId,
     ServerSecurityContext securityContext,
     DateTime creationTime,
     DateTime idleTime,
     string userName,
     int sessionGlobalId)
 {
     this.connection = connection;
     this.sessionId = sessionId;
     this.securityContext = securityContext;
     this.creationTime = creationTime;
     this.idleTime = idleTime;
     this.userName = userName;
     this.sessionGlobalId = sessionGlobalId;
     this.treeConnectTable = new Dictionary<ushort, IFileServiceServerTreeConnect>();
 }
        /// <summary>
        /// create sicily bind response packet.
        /// </summary>
        /// <param name="context">
        /// an AdtsLdapContext object that indicates the context of LDAP.
        /// </param>
        /// <param name="securityContext">
        /// a ServerSecurityContext object that specifies the security provider.
        /// </param>
        /// <param name="enableMessageSecurity">
        /// a bool value that indicates whether enable message security.
        /// </param>
        /// <returns>
        /// a SicilyBindResponsePacket object that responses the Sicily bind request.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// thrown when context is null.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// thrown when securityContext is null.
        /// </exception>
        public AdtsSicilyBindResponsePacket CreateSicilyBindResponse(
            AdtsLdapContext context, ServerSecurityContext securityContext, bool enableMessageSecurity)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (securityContext == null)
            {
                throw new ArgumentNullException("securityContext");
            }

            if (context.Security == null)
            {
                context.Security = new AdtsLdapSaslSecurityLayer(securityContext);
                context.UsingMessageSecurity = enableMessageSecurity;
            }

            return this.CreateSicilyBindResponse(
                context, ResultCode.Success, securityContext.Token, string.Empty);
        }