Esempio n. 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);
        }
Esempio n. 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);
     }
     Schema.DeviceUser deviceUser = program.CatalogDeviceSession.ResolveDeviceUser(device, user, false);
     return(deviceUser != null);
 }
Esempio n. 3
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);
 }
Esempio n. 4
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);
        }