AdsMgKillUser function

AdsMgKillUser function

Postby silvinamazzaro » Fri Oct 21, 2016 1:31 pm

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 )
silvinamazzaro
 
Posts: 61
Joined: Tue Nov 19, 2013 2:13 pm

Re: AdsMgKillUser function

Postby fgondi » Wed Oct 26, 2016 8:39 am

I use this:

Code: Select all  Expand view
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
 
Un saludo
Fernando González Diez
ALSIS Sistemas Informáticos
User avatar
fgondi
 
Posts: 694
Joined: Fri Oct 07, 2005 6:58 am
Location: Palencia, España

Re: AdsMgKillUser function

Postby silvinamazzaro » Fri Oct 28, 2016 8:49 pm

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 )
silvinamazzaro
 
Posts: 61
Joined: Tue Nov 19, 2013 2:13 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 79 guests