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); }
public override DataVar InternalExecute(ServerProcess AProcess, DataVar[] AArguments) { if (AProcess.ServerSession.Server.Catalog.Generators == null) // if not set already { // check for existing table named Datphor.Generators Schema.TableVar LTableVar = (Schema.TableVar)Compiler.ResolveCatalogIdentifier(AProcess.Plan, "System.Generators", false); if (LTableVar == null) // if system.generators doesn't already exist { // get device Schema.Device LDevice = AArguments.Length > 0 ? (Schema.Device)Compiler.ResolveCatalogIdentifier(AProcess.Plan, AArguments[0].Value.AsString, true) : Language.D4.Compiler.GetDefaultDevice(AProcess.Plan, true); // make sure the device is started so that DeviceScalarTypes is filled AProcess.EnsureDeviceStarted(LDevice); // create table type Schema.TableType LTableType = new Schema.TableType(); // use System.String if available else System.IString if (LDevice.DeviceScalarTypes.Contains(AProcess.Plan.Catalog.DataTypes.SystemIString)) { LTableType.Columns.Add(new Schema.Column("ID", AProcess.Plan.Catalog.DataTypes.SystemIString)); } else { LTableType.Columns.Add(new Schema.Column("ID", AProcess.Plan.Catalog.DataTypes.SystemString)); } LTableType.Columns.Add(new Schema.Column("NextKey", AProcess.Plan.Catalog.DataTypes.SystemInteger)); // create table LTableVar = new Schema.BaseTableVar("System.Generators", LTableType, LDevice); MetaData LMetaData = new MetaData(); LMetaData.Tags.Add(new Tag("Storage.Length", "200", false, true)); LTableVar.Columns.Add(new Schema.TableVarColumn(LTableType.Columns["ID"], LMetaData)); LTableVar.Columns.Add(new Schema.TableVarColumn(LTableType.Columns["NextKey"])); LTableVar.Keys.Add(new Schema.Key(new Schema.TableVarColumn[] { LTableVar.Columns["ID"] })); LTableVar.Owner = AProcess.Plan.User; LTableVar.Library = AProcess.Plan.CurrentLibrary; LTableVar.AddDependency(LDevice); LTableVar.AddDependency((Schema.ScalarType)LTableVar.Columns[0].DataType); LTableVar.AddDependency((Schema.ScalarType)LTableVar.Columns[1].DataType); Compiler.Bind(AProcess.Plan, new CreateTableNode((Schema.BaseTableVar)LTableVar)).Execute(AProcess); if (AProcess.Plan.User.ID == Server.Server.CAdminUserID) { Schema.Group LGroup = AProcess.Plan.Catalog.Groups[Server.Server.CUserGroupName]; LGroup.GrantRight(LTableVar.Rights.Select, true); LGroup.GrantRight(LTableVar.Rights.Insert, true); LGroup.GrantRight(LTableVar.Rights.Update, true); } } // set generator table SystemSetGeneratorsNode.SetGenerator(AProcess, LTableVar); } return(null); }
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); }
protected internal FastoreDeviceSession ( Schema.Device device, ServerProcess serverProcess, Schema.DeviceSessionInfo deviceSessionInfo, Database db ) : base(device, serverProcess, deviceSessionInfo) { _db = db; }
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); }
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); }