Example #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);
        }
Example #2
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);
 }