Exemple #1
0
        public override object InternalExecute(Program program, object[] arguments)
        {
            Schema.User   user   = ((ServerCatalogDeviceSession)program.CatalogDeviceSession).ResolveUser((string)arguments[0]);
            Schema.Device device = Compiler.ResolveCatalogIdentifier(program.Plan, (string)arguments[1], true) as Schema.Device;
            if (device == null)
            {
                throw new CompilerException(CompilerException.Codes.DeviceIdentifierExpected);
            }
            if (user.IsSystemUser())
            {
                program.Plan.CheckRight(Schema.RightNames.MaintainSystemDeviceUsers);
            }
            if (user.ID != program.Plan.User.ID)
            {
                program.Plan.CheckAuthorized(user.ID);
            }
            program.Plan.CheckRight(device.GetRight(Schema.RightNames.MaintainUsers));
            if (((ServerCatalogDeviceSession)program.CatalogDeviceSession).DeviceUserExists(device, user))
            {
                throw new Schema.SchemaException(Schema.SchemaException.Codes.DuplicateDeviceUser, user.ID, device.Name);
            }

            Schema.DeviceUser deviceUser = new Schema.DeviceUser(user, device, (string)arguments[2], (string)arguments[3]);
            if ((arguments.Length == 5) && (arguments[4] != null))
            {
                deviceUser.ConnectionParameters = (string)arguments[4];
            }

            ((ServerCatalogDeviceSession)program.CatalogDeviceSession).InsertDeviceUser(deviceUser);
            return(null);
        }
Exemple #2
0
        public override object InternalExecute(Program program, object[] arguments)
        {
            Schema.User user = ((ServerCatalogDeviceSession)program.CatalogDeviceSession).ResolveUser((string)arguments[0]);

            if ((String.Compare(user.ID, Server.Engine.SystemUserID, true) == 0) || (String.Compare(user.ID, Server.Engine.AdminUserID, true) == 0))
            {
                throw new ServerException(ServerException.Codes.CannotDropSystemUsers);
            }
            else
            {
                program.Plan.CheckRight(Schema.RightNames.DropUser);
            }

            if (((ServerCatalogDeviceSession)program.CatalogDeviceSession).UserOwnsObjects(user.ID))
            {
                throw new ServerException(ServerException.Codes.UserOwnsObjects, user.ID);
            }

            if (((ServerCatalogDeviceSession)program.CatalogDeviceSession).UserOwnsRights(user.ID))
            {
                throw new ServerException(ServerException.Codes.UserOwnsRights, user.ID);
            }

            foreach (ServerSession session in program.ServerProcess.ServerSession.Server.Sessions)
            {
                if (String.Compare(session.User.ID, user.ID, true) == 0)
                {
                    throw new ServerException(ServerException.Codes.UserHasOpenSessions, user.ID);
                }
            }

            ((ServerCatalogDeviceSession)program.CatalogDeviceSession).DeleteUser(user);

            return(null);
        }
Exemple #3
0
 public override object InternalExecute(Program program, object[] arguments)
 {
     Schema.User user = ((ServerCatalogDeviceSession)program.CatalogDeviceSession).ResolveUser((string)arguments[1], false);
     if (user != null)
     {
         SystemRevokeRightFromUserNode.RevokeRight(program, (string)arguments[0], user);
     }
     return(null);
 }
Exemple #4
0
        public override object InternalExecute(Program program, object[] arguments)
        {
            string rightName = (string)arguments[0];

            Schema.User user = ((ServerCatalogDeviceSession)program.CatalogDeviceSession).ResolveUser((string)arguments[1]);
            program.Plan.CheckAuthorized(user.ID);
            program.Plan.CheckRight(rightName);
            ((ServerCatalogDeviceSession)program.CatalogDeviceSession).RevertRightForUser(rightName, user.ID);
            return(null);
        }
Exemple #5
0
 public override object InternalExecute(Program program, object[] arguments)
 {
     Schema.User   user   = ((ServerCatalogDeviceSession)program.CatalogDeviceSession).ResolveUser((string)arguments[0]);
     Schema.Device device = Compiler.ResolveCatalogIdentifier(program.Plan, (string)arguments[1], true) as Schema.Device;
     if (device == null)
     {
         throw new CompilerException(CompilerException.Codes.DeviceIdentifierExpected);
     }
     Schema.DeviceUser deviceUser = program.CatalogDeviceSession.ResolveDeviceUser(device, user, false);
     return(deviceUser != null);
 }
Exemple #6
0
        public override object InternalExecute(Program program, object[] arguments)
        {
            Schema.User user = program.ServerProcess.ServerSession.User;
            if (String.Compare((string)arguments[0], Schema.SecurityUtility.DecryptPassword(user.Password), true) != 0)
            {
                throw new ServerException(ServerException.Codes.InvalidPassword);
            }

            ((ServerCatalogDeviceSession)program.CatalogDeviceSession).SetUserPassword(user.ID, Schema.SecurityUtility.EncryptPassword((string)arguments[1]));
            return(null);
        }
Exemple #7
0
        public override object InternalExecute(Program program, object[] arguments)
        {
            program.Plan.CheckRight(Schema.RightNames.CreateUser);
            string userID = (string)arguments[0];

            if (((ServerCatalogDeviceSession)program.CatalogDeviceSession).UserExists(userID))
            {
                throw new Schema.SchemaException(Schema.SchemaException.Codes.DuplicateUserID, userID);
            }
            Schema.User user = new Schema.User(userID, (string)arguments[1], (string)arguments[2]);
            ((ServerCatalogDeviceSession)program.CatalogDeviceSession).InsertUser(user);
            ((ServerCatalogDeviceSession)program.CatalogDeviceSession).InsertUserRole(user.ID, program.ServerProcess.ServerSession.Server.UserRole.ID);
            return(null);
        }
Exemple #8
0
        public override object InternalExecute(Program program, object[] arguments)
        {
            Schema.User user = ((ServerCatalogDeviceSession)program.CatalogDeviceSession).ResolveUser((string)arguments[0]);
            Schema.Role role = Compiler.ResolveCatalogIdentifier(program.Plan, (string)arguments[1], true) as Schema.Role;
            if (role == null)
            {
                throw new CompilerException(CompilerException.Codes.RoleIdentifierExpected);
            }

            program.Plan.CheckAuthorized(user.ID);
            // BTR 5/30/2012 -> This isn't really altering the role, so I'm removing this check
            //program.Plan.CheckRight(role.GetRight(Schema.RightNames.Alter));
            ((ServerCatalogDeviceSession)program.CatalogDeviceSession).DeleteUserRole(user.ID, role.ID);
            return(null);
        }
Exemple #9
0
 public override object InternalExecute(Program program, object[] arguments)
 {
     Schema.User   user   = ((ServerCatalogDeviceSession)program.CatalogDeviceSession).ResolveUser((string)arguments[0]);
     Schema.Device device = Compiler.ResolveCatalogIdentifier(program.Plan, (string)arguments[1], true) as Schema.Device;
     if (device == null)
     {
         throw new CompilerException(CompilerException.Codes.DeviceIdentifierExpected);
     }
     if (user.IsSystemUser())
     {
         program.Plan.CheckRight(Schema.RightNames.MaintainSystemDeviceUsers);
     }
     if (user.ID != program.Plan.User.ID)
     {
         program.Plan.CheckAuthorized(user.ID);
     }
     program.Plan.CheckRight(device.GetRight(Schema.RightNames.MaintainUsers));
     Schema.DeviceUser deviceUser = program.CatalogDeviceSession.ResolveDeviceUser(device, user);
     ((ServerCatalogDeviceSession)program.CatalogDeviceSession).DeleteDeviceUser(deviceUser);
     return(null);
 }
Exemple #10
0
        public override object InternalExecute(Program program, object[] arguments)
        {
            Schema.CatalogObject objectValue = Compiler.ResolveCatalogIdentifier(program.Plan, (string)arguments[0], false) as Schema.CatalogObject;
            if (objectValue == null)
            {
                throw new Schema.SchemaException(Schema.SchemaException.Codes.CatalogObjectExpected, objectValue.Name);
            }

            Schema.User user = ((ServerCatalogDeviceSession)program.CatalogDeviceSession).ResolveUser((string)arguments[1]);
            if (program.Plan.User.ID != user.ID)
            {
                program.Plan.CheckAuthorized(user.ID);
            }
            if (!objectValue.IsOwner(program.Plan.User))
            {
                throw new ServerException(ServerException.Codes.UnauthorizedUser, ErrorSeverity.Environment, program.Plan.User.ID);
            }
            ChangeObjectOwner(program, objectValue, user);

            return(null);
        }
Exemple #11
0
        public override object InternalExecute(Program program, object[] arguments)
        {
            Schema.Device device = Compiler.ResolveCatalogIdentifier(program.Plan, (string)arguments[0], true) as Schema.Device;
            if (device == null)
            {
                throw new CompilerException(CompilerException.Codes.DeviceIdentifierExpected);
            }
            Schema.User user = program.ServerProcess.ServerSession.User;
            if (user.ID != program.Plan.User.ID)
            {
                throw new ServerException(ServerException.Codes.UnauthorizedUser, ErrorSeverity.Environment, program.Plan.User.ID);
            }

            Schema.DeviceUser deviceUser = program.CatalogDeviceSession.ResolveDeviceUser(device, user);
            if (String.Compare((string)arguments[1], Schema.SecurityUtility.DecryptPassword(deviceUser.DevicePassword), true) != 0)
            {
                throw new ServerException(ServerException.Codes.InvalidPassword);
            }
            ((ServerCatalogDeviceSession)program.CatalogDeviceSession).SetDeviceUserPassword(deviceUser, Schema.SecurityUtility.EncryptPassword((string)arguments[2]));
            //LDeviceUser.DevicePassword = Schema.SecurityUtility.EncryptPassword((string)AArguments[2]);
            //((ServerCatalogDeviceSession)AProgram.CatalogDeviceSession).UpdateDeviceUser(LDeviceUser);
            return(null);
        }
Exemple #12
0
        public override object InternalExecute(Program program, object[] arguments)
        {
            string rightName = (string)arguments[0];

            Schema.Right right = ((ServerCatalogDeviceSession)program.CatalogDeviceSession).ResolveRight(rightName);
            Schema.User  user  = ((ServerCatalogDeviceSession)program.CatalogDeviceSession).ResolveUser((string)arguments[1]);
            if (right.IsGenerated)
            {
                throw new ServerException(ServerException.Codes.CannotDropGeneratedRight, right.Name);
            }

            if (program.Plan.User.ID != user.ID)
            {
                program.Plan.CheckAuthorized(user.ID);
            }
            if (!right.IsOwner(program.Plan.User.ID))
            {
                throw new ServerException(ServerException.Codes.UnauthorizedUser, ErrorSeverity.Environment, program.Plan.User.ID);
            }

            ((ServerCatalogDeviceSession)program.CatalogDeviceSession).SetRightOwner(rightName, user.ID);
            return(null);
        }
Exemple #13
0
 public override object InternalExecute(Program program, object[] arguments)
 {
     Schema.User user = ((ServerCatalogDeviceSession)program.CatalogDeviceSession).ResolveUser((string)arguments[0]);
     return(((ServerCatalogDeviceSession)program.CatalogDeviceSession).UserHasRight(user.ID, (string)arguments[1]));
 }
Exemple #14
0
        private void ChangeObjectOwner(Program program, Schema.CatalogObject objectValue, Schema.User user)
        {
            if (objectValue != null)
            {
                objectValue.Owner = user;
                ((ServerCatalogDeviceSession)program.CatalogDeviceSession).SetCatalogObjectOwner(objectValue.ID, user.ID);

                if (objectValue is Schema.ScalarType)
                {
                    Schema.ScalarType scalarType = (Schema.ScalarType)objectValue;

                    if (scalarType.EqualityOperator != null)
                    {
                        ChangeObjectOwner(program, scalarType.EqualityOperator, user);
                    }

                    if (scalarType.ComparisonOperator != null)
                    {
                        ChangeObjectOwner(program, scalarType.ComparisonOperator, user);
                    }

                    if (scalarType.IsSpecialOperator != null)
                    {
                        ChangeObjectOwner(program, scalarType.IsSpecialOperator, user);
                    }

                    foreach (Schema.Special special in scalarType.Specials)
                    {
                        ChangeObjectOwner(program, special.Selector, user);
                        ChangeObjectOwner(program, special.Comparer, user);
                    }

                                        #if USETYPEINHERITANCE
                    foreach (Schema.Operator operatorValue in scalarType.ExplicitCastOperators)
                    {
                        ChangeObjectOwner(AProgram, operatorValue, AUser);
                    }
                                        #endif

                    foreach (Schema.Representation representation in scalarType.Representations)
                    {
                        if (representation.Selector != null)
                        {
                            ChangeObjectOwner(program, representation.Selector, user);
                        }

                        foreach (Schema.Property property in representation.Properties)
                        {
                            if (property.ReadAccessor != null)
                            {
                                ChangeObjectOwner(program, property.ReadAccessor, user);
                            }
                            if (property.WriteAccessor != null)
                            {
                                ChangeObjectOwner(program, property.WriteAccessor, user);
                            }
                        }
                    }
                }
            }
        }
Exemple #15
0
 public static void GrantRight(Program program, Schema.User user, string rightName)
 {
     program.Plan.CheckAuthorized(user.ID);
     program.Plan.CheckRight(rightName);
     ((ServerCatalogDeviceSession)program.CatalogDeviceSession).GrantRightToUser(rightName, user.ID);
 }
Exemple #16
0
 public override object InternalExecute(Program program, object[] arguments)
 {
     Schema.User user = ((ServerCatalogDeviceSession)program.CatalogDeviceSession).ResolveUser((string)arguments[1]);
     RevokeRight(program, (string)arguments[0], user);
     return(null);
 }
Exemple #17
0
 public static void RevokeRight(Program program, string rightName, Schema.User user)
 {
     program.Plan.CheckAuthorized(user.ID);
     program.Plan.CheckRight(rightName);
     ((ServerCatalogDeviceSession)program.CatalogDeviceSession).RevokeRightFromUser(rightName, user.ID);
 }