コード例 #1
0
        // Retrieves the user record
        private DataSet Retrieve(string sUserName, string sPassword)
        {
            DataSet   dsUser = new DataSet();
            DataTable dtUser = new DataTable();
            DataRow   drUser;
            string    sPasswordSalt;

            // Since the Northwind database does not have a user table, just generate the dataset

            // Add the columns to the table
            dtUser.Columns.Add(FN_USER_NAME);
            dtUser.Columns.Add(FN_PASSWORD_ENCODED);
            dtUser.Columns.Add(FN_PASSWORD_SALT);
            dtUser.Columns.Add(FN_STATUS);

            // Add the data to the row
            drUser = dtUser.NewRow();
            drUser[FN_USER_NAME]        = "DeborahK";
            sPasswordSalt               = SecurityUtility.ComputeSalt();
            drUser[FN_PASSWORD_ENCODED] = SecurityUtility.ComputeHash(sPasswordSalt + sPassword);
            drUser[FN_PASSWORD_SALT]    = sPasswordSalt;
            drUser[FN_STATUS]           = STATUS_ACTIVE;

            //Add the row to the table
            dtUser.Rows.Add(drUser);

            // Add the table to the dataset
            dsUser.Tables.Add(dtUser);

            // Set the table name
            dsUser.Tables[0].TableName = TN_USER;

            return(dsUser);
        }