Page 1 of 1
AdsMgKillUser function
Posted: Fri Oct 21, 2016 1:31 pm
by silvinamazzaro
Hello :
Someone used successfully AdsMgKillUser function?
and I can indicate as used ..?
I wrote the following but does not kill me users ...
Thank you
Silvina
FUNCTION KILL_OPERADORES
*=======================
LOCAL aUsuarios , nFor
AdsMgConnect( 'n:' )
aUsuarios := AdsMgGetUserNames()
FOR nFor := 1 TO len( aUsuarios )
AdsMgKillUser( , aUsuarios[ nFor ][ 1 ] , 0 )
NEXT
AdsMgDisconnect()
Return( Nil )
Re: AdsMgKillUser function
Posted: Wed Oct 26, 2016 8:39 am
by fgondi
I use this:
Code: Select all
cSql:= "EXECUTE PROCEDURE sp_mgGetConnectedUsers()"
Try
oAdoComando:CommandText := rTrim(cSql)
oRecordSet := oAdoComando:Execute()
Catch
oRecordSet := NIL
End
aDatos := {}
aServer := {}
if oRecordSet<>NIL
WHILE !oRecordSet:Eof
cReg := oRecordSet:fields('USERNAME'):Value
cReg := Alltrim( Upper( cReg ) )
cUser := oRecordSet:fields('DICTIONARYUSER'):Value
cUser := Alltrim( Upper( cUser ) )
if !cUser=='ADSSYS' .and. !(cReg in aDatos) .and. !(cReg in aServer) //... Sólo una ejecución por equipo conectado
aadd( aDatos, cReg )
elseif cUser=='ADSSYS' .and. !(cReg in aServer)
j := aScan( aDatos, cReg )
if j<>0
aDatos := Hb_aDel( aDatos, j, .T. )
endif
aadd( aServer, cReg )
endif
oRecordSet:MoveNext()
END
oRecordSet:Close()
endif
oRecordSet := NIL
j := len(aDatos)
for i := 1 to j
for each cReg in aDatos
Try
cSql := "EXECUTE PROCEDURE sp_mgKillUser('"+cReg+"')"
oAdoComando:CommandText := rTrim(cSql)
oAdoComando:Execute()
Catch
End
next
next
j := len(aServer)
for each cReg in aServer
Try
cSql := "EXECUTE PROCEDURE sp_mgKillUser('"+cReg+"')"
oAdoComando:CommandText := rTrim(cSql)
oAdoComando:Execute()
Catch
End
next
Re: AdsMgKillUser function
Posted: Fri Oct 28, 2016 8:49 pm
by silvinamazzaro
por si a alguien le interesa, lo hicimos andar de la siguiente forma:
esto cancela las aplicaciones conectadas al la bdd y cierra los archivos.
sldos
Silvina
FUNCTION BDDKILL
*===============
LOCAL aUsuarios , nFor , nManejador
AdsMgConnect( 'W:' ) //, nil, nil, @nManejador )
aUsuarios := AdsMgGetUserNames()
FOR nFor := 1 TO len( aUsuarios )
msginfo( aUsuarios[ nFor ][ 1 ] )
AdsMgKillUser( aUsuarios[ nFor ][ 1 ] , 0 )
NEXT
AdsMgDisconnect()
Return( Nil )