예제 #1
0
        public Connection(PathSet pathSet, ParamSet paramSet) : base()
        {
            this.IsConnected = false;

            if (pathSet == null)
            {
                this.AddError("Constructor", "Required pathSet.");

                return;
            }

            this._pathSet = pathSet;
            var argParamSet = (paramSet == null)
                ? new ParamSet()
                : paramSet.Clone();

            if (argParamSet.SmbType == null)
            {
                this._client
                    = this.GetConnection(SmbType.Smb2)
                      ?? this.GetConnection(SmbType.Smb1);
            }
            else if (argParamSet.SmbType == SmbType.Smb2)
            {
                this._client = this.GetConnection(SmbType.Smb2);
            }
            else if (argParamSet.SmbType == SmbType.Smb1)
            {
                this._client = this.GetConnection(SmbType.Smb1);
            }
            else
            {
                this.AddError("Constructor", $"Unexpected ParamSet.SmbType: {argParamSet.SmbType}");

                return;
            }

            if (this._client == null)
            {
                this.AddError("Constructor", "Connection Failed.");

                return;
            }

            if (!this.Login(argParamSet))
            {
                this.AddError("Constructor", "Authentication Failed.");

                return;
            }

            this._paramSet = FixedParamSet.Parse(
                argParamSet,
                (this._client is SMB2Client)
                    ? SmbType.Smb2
                    : SmbType.Smb1
                );

            this.IsConnected = true;
        }