Esempio n. 1
0
        /// <summary>
        /// Get information about a web service user.
        /// This method should only be used for logging purpose
        /// when client token is not accepted.
        /// </summary>
        /// <param name="userName">User name.</param>
        /// <returns>
        /// Returns user information or null if
        /// user information is not valid.
        /// It is only during login that the
        /// user information can be invalid.
        /// </returns>
        public virtual WebUser GetUser(String userName)
        {
            WebUser user;

            // Check data.
            userName.CheckNotEmpty("userName");
            userName = userName.CheckInjection();

            // Get information from database.
            user = null;
            using (UserServer database = new UserServer())
            {
                using (DataReader dataReader = database.GetUser(userName))
                {
                    if (dataReader.Read())
                    {
                        user = new WebUser();
                        user.LoadData(dataReader);
                    }
                }
            }

            return(user);
        }