VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "c_seguridad"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
Public Function ValidarUsuario(ByVal StrCodigoUsuario As String, ByVal StrPassWord As String, Optional VarAux As Variant) As Integer
       
Dim cmd As ADODB.Command
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSql As String

On Error GoTo ErrorHandler
'Funcion de Encriptación del password
    ValidarUsuario = 0  'OK
    
    strSql = "select userid,password,expired,status from se_userrec where userid='" & StrCodigoUsuario & "'"
        
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    Set con = New ADODB.Connection
    con.ConnectionString = "FILEDSN=conexionsies"
    con.Open
    rs.Open strSql, con, adOpenDynamic, adLockBatchOptimistic
    
    If rs.RecordCount = 0 Or rs.EOF Then
        ValidarUsuario = 1  'USUARIO NO EXISTE
        Exit Function
    End If
    
    If Trim(rs!Password) <> Trim(StrPassWord) Then
        ValidarUsuario = 2  'CLAVE INCORRECTA
    End If
    
    'If rs!expired < Date And StrCodigoUsuario <> "system" Then
    '    ValidarUsuario = 3  'expiro
    'End If
    
    If rs!Status = 0 Then
        ValidarUsuario = 4  'inactivo
    End If
    
 'GetObjectContext.SetComplete
 
Exit Function
    
ErrorHandler:
Dim LStrMensajeError As String
Dim LVarNumeroError As Variant
    
     If Not rs Is Nothing Then
        Set rs = Nothing
     End If
     If Not cmd Is Nothing Then
        Set cmd = Nothing
     End If
     If Not con Is Nothing Then
        LStrMensajeError = con.Errors(con.Errors.Count - 1).Description
        LVarNumeroError = con.Errors(con.Errors.Count - 1).NativeError
        Set con = Nothing
     End If
     
     'GetObjectContext.SetAbort
     Err.Raise LVarNumeroError, "DB_SE_MANTENIMIENTOS.ValidarUsuario", LStrMensajeError
     
End Function
Public Function listar_derechosUsuario(ByVal StrCodigoUsuario As String, ByVal Strscreenid As String, Optional VarAux As Variant) As ADODB.Recordset
 
Dim cmd As ADODB.Command
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSql As String

On Error GoTo ErrorHandler
    
'Funcion de Encriptación del password
    
    strSql = " select * from vw_derechos where userid='" + StrCodigoUsuario + "' and screenid='" + Strscreenid + "'"
        
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    Set con = New ADODB.Connection
    con.ConnectionString = "FILEDSN=conexionsies"
    con.Open
    rs.Open strSql, con, adOpenDynamic, adLockBatchOptimistic
    
    Set listar_derechosUsuario = rs
    
 'GetObjectContext.SetComplete
 
Exit Function
    
ErrorHandler:
Dim LStrMensajeError As String
Dim LVarNumeroError As Variant
    
     If Not rs Is Nothing Then
        Set rs = Nothing
     End If
     If Not cmd Is Nothing Then
        Set cmd = Nothing
     End If
     If Not con Is Nothing Then
        LStrMensajeError = con.Errors(con.Errors.Count - 1).Description
        LVarNumeroError = con.Errors(con.Errors.Count - 1).NativeError
        Set con = Nothing
     End If
     
     'GetObjectContext.SetAbort
     Err.Raise LVarNumeroError, "DB_SE_MANTENIMIENTOS.listar_derechosUsuario", LStrMensajeError
     
End Function
Public Function listar_derechosgrupousuario(ByVal StridUsuario As String, ByVal STRTIPO As String, Optional VarAux As Variant) As ADODB.Recordset
       
Dim cmd As ADODB.Command
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSql As String

On Error GoTo ErrorHandler
    
If STRTIPO = "Usuario" Then
    strSql = "select screenid,screenname,viewrights,insertrights,updaterights,deleterights,printrights,nullrights,closerights from vw_derechosusuarios where userid='" + StridUsuario + "' order by screenid "
Else
    strSql = "select screenid,screenname,viewrights,insertrights,updaterights,deleterights,printrights,nullrights,closerights from vw_derechosgrupos where userid='" + StridUsuario + "' order by screenid "
End If
        
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    Set con = New ADODB.Connection
    con.ConnectionString = "FILEDSN=conexionsies"
    con.Open
    rs.Open strSql, con, adOpenDynamic, adLockBatchOptimistic
    
    Set listar_derechosgrupousuario = rs
    
 'GetObjectContext.SetComplete
 
Exit Function
    
ErrorHandler:
Dim LStrMensajeError As String
Dim LVarNumeroError As Variant
    
     If Not rs Is Nothing Then
        Set rs = Nothing
     End If

     If Not con Is Nothing Then
        LStrMensajeError = con.Errors(con.Errors.Count - 1).Description
        LVarNumeroError = con.Errors(con.Errors.Count - 1).NativeError
        Set con = Nothing
     End If
     
     'GetObjectContext.SetAbort
     Err.Raise LVarNumeroError, "DB_SE_MANTENIMIENTOS.listar_derechosgrupousuario", LStrMensajeError
     
End Function
Public Function GRUPOSPOSIBLES_usuario(ByVal struserid As String, Optional VarAux As Variant) As ADODB.Recordset
Dim cmd As ADODB.Command
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSql As String
On Error GoTo ErrorHandler

    strSql = "select groupid,groupname from VW_GRUPOSPOSIBLES where userid='" + struserid + "'"
    
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    Set con = New ADODB.Connection
    con.ConnectionString = "FILEDSN=conexionsies"
    con.Open
    rs.Open strSql, con, adOpenDynamic, adLockBatchOptimistic
    Set GRUPOSPOSIBLES_usuario = rs
    
 'GetObjectContext.SetComplete

Exit Function
    
ErrorHandler:
Dim LStrMensajeError As String
Dim LVarNumeroError As Variant
    
     If Not rs Is Nothing Then
        Set rs = Nothing
     End If
     If Not con Is Nothing Then
        LStrMensajeError = con.Errors(con.Errors.Count - 1).Description
        LVarNumeroError = con.Errors(con.Errors.Count - 1).NativeError
        Set con = Nothing
     End If
     'GetObjectContext.SetAbort
     Err.Raise LVarNumeroError, "DB_SE_MANTENIMIENTOS.GRUPOSPOSIBLES_usuario", LStrMensajeError
     
End Function
Public Function usuariosgrupos_usuario(ByVal struserid As String, Optional VarAux As Variant) As ADODB.Recordset
Dim cmd As ADODB.Command
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSql As String
On Error GoTo ErrorHandler

    strSql = "select groupid,groupname from vw_usuariosgrupos where userid='" + struserid + "'"
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    Set con = New ADODB.Connection
    con.ConnectionString = "FILEDSN=conexionsies"
    con.Open
    rs.Open strSql, con, adOpenDynamic, adLockBatchOptimistic
    Set usuariosgrupos_usuario = rs
    
 'GetObjectContext.SetComplete
 
Exit Function
    
ErrorHandler:
Dim LStrMensajeError As String
Dim LVarNumeroError As Variant
    
     If Not rs Is Nothing Then
        Set rs = Nothing
     End If
     If Not con Is Nothing Then
        LStrMensajeError = con.Errors(con.Errors.Count - 1).Description
        LVarNumeroError = con.Errors(con.Errors.Count - 1).NativeError
        Set con = Nothing
     End If
     'GetObjectContext.SetAbort
     Err.Raise LVarNumeroError, "DB_SE_MANTENIMIENTOS.usuariosgrupos", LStrMensajeError
     
End Function


Public Function GRUPOSPOSIBLES_grupo(ByVal strgrupoid As String, Optional VarAux As Variant) As ADODB.Recordset
Dim cmd As ADODB.Command
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSql As String
On Error GoTo ErrorHandler

strSql = "select userid,username from VW_GRUPOSPOSIBLES where groupid='" + strgrupoid + "'"
    Set rs = New ADODB.Recordset
        rs.CursorLocation = adUseClient
    Set con = New ADODB.Connection
    con.ConnectionString = "FILEDSN=conexionsies"
    con.Open
    rs.Open strSql, con, adOpenDynamic, adLockBatchOptimistic
    Set GRUPOSPOSIBLES_grupo = rs
 'GetObjectContext.SetComplete
Exit Function
ErrorHandler:
Dim LStrMensajeError As String
Dim LVarNumeroError As Variant
    
     If Not rs Is Nothing Then
        Set rs = Nothing
     End If
     If Not con Is Nothing Then
        LStrMensajeError = con.Errors(con.Errors.Count - 1).Description
        LVarNumeroError = con.Errors(con.Errors.Count - 1).NativeError
        Set con = Nothing
     End If
     'GetObjectContext.SetAbort
     Err.Raise LVarNumeroError, "DB_SE_MANTENIMIENTOS.GRUPOSPOSIBLES_grupo", LStrMensajeError
End Function
Public Function usuariosgrupos_grupo(ByVal strgrupoid As String, Optional VarAux As Variant) As ADODB.Recordset
Dim cmd As ADODB.Command
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSql As String
On Error GoTo ErrorHandler
    strSql = "select userid,username from vw_usuariosgrupos where groupid='" + strgrupoid + "'"
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    
    Set con = New ADODB.Connection
    con.ConnectionString = "FILEDSN=conexionsies"
    con.Open
    rs.Open strSql, con, adOpenStatic
    Set usuariosgrupos_grupo = rs
    
 'GetObjectContext.SetComplete
 
Exit Function
    
ErrorHandler:
Dim LStrMensajeError As String
Dim LVarNumeroError As Variant
    
     If Not rs Is Nothing Then
        Set rs = Nothing
     End If
     If Not con Is Nothing Then
        LStrMensajeError = con.Errors(con.Errors.Count - 1).Description
        LVarNumeroError = con.Errors(con.Errors.Count - 1).NativeError
        Set con = Nothing
     End If
     'GetObjectContext.SetAbort
     Err.Raise LVarNumeroError, "DB_SE_MANTENIMIENTOS.usuariosgrupos", LStrMensajeError
     
End Function
Public Function existe_derechosUsuario(ByVal StrCodigoUsuario As String, ByVal Strscreenid As String, Optional VarAux As Variant) As Boolean
 
Dim cmd As ADODB.Command
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSql As String
On Error GoTo ErrorHandler
    
    strSql = " select userid from se_accessdetrights where userid='" + StrCodigoUsuario + "' and screenid='" + Strscreenid + "'"
        
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    Set con = New ADODB.Connection
    con.ConnectionString = "FILEDSN=conexionsies"
    con.Open
    rs.Open strSql, con, adOpenDynamic, adLockBatchOptimistic
    
    existe_derechosUsuario = Not rs.EOF
    
 'GetObjectContext.SetComplete
 
Exit Function
    
ErrorHandler:
Dim LStrMensajeError As String
Dim LVarNumeroError As Variant
     If Not rs Is Nothing Then
        Set rs = Nothing
     End If
     If Not cmd Is Nothing Then
        Set cmd = Nothing
     End If
     If Not con Is Nothing Then
        LStrMensajeError = con.Errors(con.Errors.Count - 1).Description
        LVarNumeroError = con.Errors(con.Errors.Count - 1).NativeError
        Set con = Nothing
     End If
     
     'GetObjectContext.SetAbort
     Err.Raise LVarNumeroError, "DB_SE_MANTENIMIENTOS.listar_derechosUsuario", LStrMensajeError
End Function

Public Function Auxiliar1(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_SE_MANTENIMIENTOS.c_seguridad.Auxiliar1", Err.Description
End Function

Public Function Auxiliar2(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_SE_MANTENIMIENTOS.c_seguridad.Auxiliar2", Err.Description
End Function

Public Function Auxiliar3(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_SE_MANTENIMIENTOS.c_seguridad.Auxiliar3", Err.Description
End Function

Public Function Auxiliar4(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_SE_MANTENIMIENTOS.c_seguridad.Auxiliar4", Err.Description
End Function

Public Function Auxiliar5(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_SE_MANTENIMIENTOS.c_seguridad.Auxiliar5", Err.Description
End Function


Public Function Auxiliar6(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_SE_MANTENIMIENTOS.c_seguridad.Auxiliar6", Err.Description
End Function

Public Function Auxiliar7(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_SE_MANTENIMIENTOS.c_seguridad.Auxiliar7", Err.Description
End Function

Public Function Auxiliar8(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_SE_MANTENIMIENTOS.c_seguridad.Auxiliar8", Err.Description
End Function

Public Function Auxiliar9(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_SE_MANTENIMIENTOS.c_seguridad.Auxiliar9", Err.Description
End Function

Public Function Auxiliar10(Optional ByVal VarAux1 As Variant, Optional ByVal VarAux2 As Variant) As Variant
    ' Funcion
    
    On Error GoTo errhandler
    
    
    
    'GetObjectContext.SetComplete
    
    Exit Function
errhandler:
    'GetObjectContext.SetAbort
    Err.Raise Err.Number, "DB_SE_MANTENIMIENTOS.c_seguridad.Auxiliar10", Err.Description
End Function






