Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Bases de datos > Firebird e Interbase
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 18-11-2005
Avatar de Jesús Pena
Jesús Pena Jesús Pena is offline
Miembro
 
Registrado: nov 2005
Posts: 88
Poder: 19
Jesús Pena Va por buen camino
Question Problemas al crear un usuario en Firebird

Utilizo Delphi 2005 y Firebird 1.5 y al intentar dar de alta un usuario a la base de datos me aparece el siguiente mensaje de error

Project xxxxxxxxxxxxxxxx.exe raised exception class EibInterbaseError with message 'attempt to store duplicate value (visible to active transactions) in
unique index "USER_NAME_INDEX"' (donde xxxxxxxxxxxxxxxx.exe es mi projecto).

Utilizo los Servicios de Interbase (AddUser).

El problema me surge en un proceso de mantenimiento de usuarios y permisos de acceso a ciertas partes del proyecto. Creo un usuario, lo elimino y lo vuelvo a crear y es cuando salta el error en cuestión.

Espero que alguno de vosotros me pueda ayudar con el tema
Responder Con Cita
  #2  
Antiguo 21-11-2005
Avatar de Al González
[Al González] Al González is offline
In .pas since 1991
 
Registrado: may 2003
Posts: 5.604
Poder: 29
Al González Es un diamante en brutoAl González Es un diamante en brutoAl González Es un diamante en brutoAl González Es un diamante en bruto
Smile

¡Hola a todos!

Tal parece que el usuario que mencionas no está siendo eliminado. Por lo tanto, al intentar crearlo de nuevo, se genera el error indicado.

¿Podrías detallarnos el proceso de eliminación que utilizas?

Un abrazo único.

Al González.
Responder Con Cita
  #3  
Antiguo 21-11-2005
Avatar de Jesús Pena
Jesús Pena Jesús Pena is offline
Miembro
 
Registrado: nov 2005
Posts: 88
Poder: 19
Jesús Pena Va por buen camino
Lightbulb Las Rutinas que utilizo son las siguientes

{------------------------ Creación-Modificación --------------------------------
Creación: 29/07/2005 Por: Jesús Pena Iglesias
Modificada:
------------------------------- Parámetros ------------------------------------
Entrada:
Salida:
--------------------------------Propósito---------------------------------------
* Aceptamos los datos
-------------------------------------------------------------------------------}
Código Delphi [-]
procedure TfrmUsuarios.bbAceptarClick(Sender: TObject);
begin
inherited;
if dsPrincipal.State = dsEdit then
begin
with dmUsuarios.IBSecurityService1 do
begin
FirstName := DBENombre.Text;
LastName := DBeApellido2.text;
MiddleName := DBEApellido1.Text;
UserName := dbeUsuario.Text;
Password := DBEPassword.Text;
Protocol := Local;
If RadioGroup1.ItemIndex = 1 then
begin
Protocol := TCP;
ServerName := eServidor.Text;
end;
try
Active := True;
ModifyUser;
Active := False;
except
on E: EIBInterbaseError do
raise Exception.Create('Error Modificando el Usuario de la base de datos del Sistema'+#13+'Error ');
end;
end;
dmUsuarios.EstablecerPermisos(dbeUsuario.Text);
// DataSetPost2.Execute;
end;
if dsPrincipal.State = dsInsert then
begin
with dmUsuarios.IBSecurityService1 do
begin
FirstName := DBENombre.Text;
LastName := DBeApellido2.text;
MiddleName := DBEApellido1.Text;
UserName := dbeUsuario.Text;
Password := DBEPassword.text;
Protocol := Local;
If RadioGroup1.ItemIndex = 1 then
begin
Protocol := TCP;
ServerName := eServidor.Text;
end;
try
Active := True;
AddUser;
Active := False;
except
on E: EIBInterbaseError do
raise Exception.Create('Error Creando el Usuario de la base de datos del Sistema'+#13+'Error ');
end;
end;
dmUsuarios.EstablecerPermisos(dbeUsuario.Text);
end;
DataSetPost2.Execute;
end;
{------------------------ Creación-Modificación --------------------------------
Creación: 29/07/2005 Por: Jesús Pena Iglesias
Modificada:
------------------------------- Parámetros ------------------------------------
Entrada:
Salida:
--------------------------------Propósito---------------------------------------
* Realizamos los procesos vinculados al borrado de un usuario
-------------------------------------------------------------------------------}
procedure TfrmUsuarios.tbBorrarClick(Sender: TObject);
begin
with dmUsuarios.IBSecurityService1 do
begin
FirstName := dmUsuarios.IBTUsuarios.FieldByName('Nombre').AsString;
LastName := dmUsuarios.IBTUsuarios.FieldbyName('APELLIDO2').AsString;
MiddleName := dmUsuarios.IBTUsuarios.FieldByName('APELLIDO1').AsString;
UserName := dmUsuarios.IBTUsuarios.FieldByName('USUARIO').AsString;;
Password := password;
If RadioGroup1.ItemIndex = 0 then
Protocol := Local
else
begin
Protocol := TCP;
ServerName := eServidor.Text;
end;
try
Active := True;
DeleteUser;
Active := False;
dmUsuarios.QuitarTodosPermisos(dmUsuarios.IBSecurityService1.UserName);
except
MessageBox(0, 'Error Borrando el Usuario de la base de datos del Sistema', 'Error', MB_ICONERROR or MB_OK);
end;
end;
inherited;
 
end;
 
Las rutinas EstablecerPermisos y QuitarTodosPermisos 
procedure TdmUsuarios.EstablecerPermisos(pUsuario: String);
var
i:Integer;
begin
with IBQPermisos do
begin
Sql.Clear;
sql.Add('GRANT xxxx TO ' + pUsuario); {Establecer permisos del Roll al usuario}
Prepare;
ExecSQL;
end;
with IBQDBOjects do
begin
If Active then Close;
Open;
First;
while not eof do
begin
with IBQPermisos do
begin
with Sql do
begin
Clear;
Add('GRANT ALL ON ' + IBQDBOjects.FieldByName('OBJETO').AsString + ' TO '+ pUsuario + ' WITH GRANT OPTION');
Prepare;
ExecSQL;
end;
end;
Next;
end;
If IBTUsuarios.FieldByName('VIAJES').AsInteger <> 1 then
begin
Sql.Clear;
sql.Add('REVOKE INSERT, UPDATE, DELETE ON DESTINOS FROM ' + pUsuario);
Prepare;
ExecSQL;
end;{If IBTUsuarios.FieldByName('VIAJES').AsInteger <> 1 then}
If IBTUsuarios.FieldByName('RUTAS').AsInteger <> 1 then
begin
Sql.Clear;
sql.Add('REVOKE INSERT, UPDATE, DELETE ON DESTINOS_VIAJES FROM ' + pUsuario);
Prepare;
ExecSQL;
Sql.Clear;
sql.Add('REVOKE INSERT, UPDATE, DELETE ON DESTINOS_VIAJES_PROGRAM FROM ' + pUsuario);
Prepare;
ExecSQL;
end; {If IBTUsuarios.FieldByName('RUTAS').AsInteger <> 1 then}
If iBTUsuarios.FieldByName('ZONAS').AsInteger <> 1 then
begin
Sql.Clear;
sql.Add('REVOKE INSERT, UPDATE, DELETE ON ZONAS FROM ' + pUsuario);
Prepare;
ExecSQL;
end;{If iBTUsuarios.FieldByName('ZONAS').AsInteger <> 1 then}
end;
end;
procedure TdmUsuarios.QuitarTodosPermisos(pUsuario: String);
begin
with IBQDBOjects do
begin
If Active then Close;
Open;
First;
while not eof do
begin
with IBQPermisos do
begin
with Sql do
begin
Clear;
Add('REVOKE ALL ON ' + IBQDBOjects.FieldByName('OBJETO').AsString + ' FROM '+ pUsuario + ' WITH GRANT OPTION');
Prepare;
ExecSQL;
end;
end;
Next;
end;
with IBQPermisos do
begin
Sql.Clear;
sql.Add('REVOKE xxxx FROM ' + pUsuario);{Eliminar los permisos del Roll al usuario}
Prepare;
ExecSQL;
end;
end;
end;

Última edición por vtdeleon fecha: 21-11-2005 a las 13:20:49. Razón: Etiqueta Delphi
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 03:12:11.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi