Deveel.Data.Sql.Statements.CreateUserStatement.ExecuteStatement C# (CSharp) Méthode

ExecuteStatement() protected méthode

protected ExecuteStatement ( ExecutionContext context ) : void
context ExecutionContext
Résultat void
        protected override void ExecuteStatement(ExecutionContext context)
        {
            if (Identifier.Type != SqlIdentificationType.Password)
                throw new NotSupportedException(String.Format("The identification type '{0}' is not supported yet.", Identifier.Type));

            var password = Identifier.Argument;
            var evaluated = password.EvaluateToConstant(context.Request, null);
            var passwordText = evaluated.AsVarChar().Value.ToString();

            if (context.DirectAccess.UserExists(UserName))
                throw new SecurityException(String.Format("The user '{0}' already exists.", UserName));
            if (context.DirectAccess.RoleExists(UserName))
                throw new SecurityException(String.Format("A role named '{0}' already exists.", UserName));

            context.DirectAccess.CreateUser(UserName, passwordText);
        }