Busqueda de Usuarios

05/10/2006 - 13:04 por nannyta | Informe spam
Hola, una pregunta...


Alguien sabe como puedo averiguar qué usuarios (ya creados) no han
iniciado sesion en X cantidad de tiempo?


Por ej.

Quiero saber que usuarios llevan mas de 6 meses sin iniciar sesion.


Con el Visor de sucesos (Seguridad) se me peta el archivo al tratar de
abrirlo, ya que pesa 50 megas x_X

ayuda!


Graciaaaaaaaaaaaaaaaaaaas :D

nanny.

Preguntas similare

Leer las respuestas

#6 nannyta
13/10/2006 - 13:52 | Informe spam
Fernando, esa linea la agregué yo :P
y el programa lo ejecute desde la ventana de comandos, y me abria
popups :)
ahora ya no me abre popups, sino que me los deja en usuariosAD.txt ;)

Saludos.

Adriana.



Fernando Reyes [MS MVP] ha escrito:

Bastaba con que lo ejecutaras con cscript, desde una ventana de comandos, en
lugar de wscript, que es usado al hacer doble click sobre el script, para
que se volcara a una ventana de comandos; si utilizas redirección de salida
puedes crear el fichero de texto; es decir, si lo hibieses lanzado así (tal
y como indica Richard Mueller en el enlace que te puse):

cscript //nologo LastLogon.vbs > "C:\temp\usuariosAD.txt"
Un saludo
Fernando Reyes [MS MVP]
MCSE Windows 2000 / 2003
MCSA Windows Server 2003
http://freyes.svetlian.com
http://www.bloglines.com/blog/urpiano

(Quítate el mono si quieres escribirme)



Y fue nannyta () quien en el mensaje
, planeando sobre su
teclado, hizo un picado y tecleó:

> Fernando y Pablo:
>
> Muchas gracias por la ayuda, bajé el script que me indicó Fernando y
> lo modifiqué, para que así, en vez de enviar un POPUP indicando la
> fecha en que cada usuario hizo su logon por ultima vez, te lo envíe a
> un TXT. y así se puede editar.
>
> Les dejo aqui el script modificado, solo lo tienen que guardar como
> .vbs y al ejecutarlo, en c:/temp (deben crear esa carpeta) se creará
> un archivo txt con todos los usuarios del AD y las respectivas fechas
> de Logon.
>
> GRACIAS!!!!
> ' Copyright (c) 2002 Richard L. Mueller
> ' Hilltop Lab web site - http://www.rlmueller.net
> ' Version 1.0 - December 7, 2002
> ' Version 1.1 - January 17, 2003 - Account for null value for
> lastLogon.
> ' Version 1.2 - January 23, 2003 - Account for DC not available.
> ' Version 1.3 - February 3, 2003 - Retrieve users but not contacts.
> ' Version 1.4 - February 19, 2003 - Standardize Hungarian notation.
> ' Version 1.5 - March 11, 2003 - Remove SearchScope property.
> ' Version 1.6 - May 9, 2003 - Account for error in IADsLargeInteger
> ' property methods HighPart and LowPart.
> ' Version 1.7 - January 25, 2004 - Modify error trapping.
> ' Version 1.8 - October 13, 2006 - La modificacion que se hace es
> cambiar los popap por un txt.
> '
> ' Because the lastLogon attribute is not replicated, every Domain
> ' Controller in the domain must be queried to find the latest
> lastLogon ' date for each user. The lastest date found is kept in a
> dictionary ' object. The program first uses ADO to search the domain
> for all Domain
> ' Controllers. The AdsPath of each Domain Controller is saved in an
> ' array. Then, for each Domain Controller, ADO is used to search the
> ' copy of Active Directory on that Domain Controller for all user
> ' objects and return the lastLogon attribute. The lastLogon attribute
> is
> ' a 64-bit number representing the number of 100 nanosecond intervals
> ' since 12:00 am January 1, 1601. This value is converted to a date.
> The
> ' last logon date is in UTC (Coordinated Univeral Time). It must be
> ' adjusted by the Time Zone bias in the machine registry to convert to
> ' local time.
> '
> ' You have a royalty-free right to use, modify, reproduce, and
> ' distribute this script file in any way you find useful, provided
> that ' you agree that the copyright owner above has no warranty,
> obligations,
> ' or liability for such use.
>
> Option Explicit
>
> Dim objRootDSE, strConfig, objConnection, objCommand, strQuery
> Dim objRecordSet, objDC
> Dim strDNSDomain, objShell, lngBiasKey, lngBias, k, arrstrDCs()
> Dim strDN, dtmDate, objDate, lngDate, objList, strUser
> Dim strBase, strFilter, strAttributes, lngHigh, lngLow
>
> ' Use a dictionary object to track latest lastLogon for each user.
> Set objList = CreateObject("Scripting.Dictionary")
> objList.CompareMode = vbTextCompare
>
> ' Obtain local Time Zone bias from machine registry.
> Set objShell = CreateObject("Wscript.Shell")
> lngBiasKey = objShell.RegRead("HKLM\System\CurrentControlSet\Control\"
> _
> & "TimeZoneInformation\ActiveTimeBias")
> If UCase(TypeName(lngBiasKey)) = "LONG" Then
> lngBias = lngBiasKey
> ElseIf UCase(TypeName(lngBiasKey)) = "VARIANT()" Then
> lngBias = 0
> For k = 0 To UBound(lngBiasKey)
> lngBias = lngBias + (lngBiasKey(k) * 256^k)
> Next
> End If
>
> ' Determine configuration context and DNS domain from RootDSE object.
> Set objRootDSE = GetObject("LDAP://RootDSE")
> strConfig = objRootDSE.Get("configurationNamingContext")
> strDNSDomain = objRootDSE.Get("defaultNamingContext")
>
> ' Use ADO to search Active Directory for ObjectClass nTDSDSA.
> ' This will identify all Domain Controllers.
> Set objCommand = CreateObject("ADODB.Command")
> Set objConnection = CreateObject("ADODB.Connection")
> objConnection.Provider = "ADsDSOObject"
> objConnection.Open "Active Directory Provider"
> objCommand.ActiveConnection = objConnection
>
> strBase = "<LDAP://" & strConfig & ">"
> strFilter = "(objectClass=nTDSDSA)"
> strAttributes = "AdsPath"
> strQuery = strBase & ";" & strFilter & ";" & strAttributes &
> ";subtree"
>
>
> objCommand.CommandText = strQuery
> objCommand.Properties("Page Size") = 100
> objCommand.Properties("Timeout") = 60
> objCommand.Properties("Cache Results") = False
>
> Set objRecordSet = objCommand.Execute
>
> ' Enumerate parent objects of class nTDSDSA. Save Domain Controller
> ' AdsPaths in dynamic array arrstrDCs.
> k = 0
> Do Until objRecordSet.EOF
> Set objDC = _
> GetObject(GetObject(objRecordSet.Fields("AdsPath")).Parent)
> ReDim Preserve arrstrDCs(k)
> arrstrDCs(k) = objDC.DNSHostName
> k = k + 1
> objRecordSet.MoveNext
> Loop
>
> ' Retrieve lastLogon attribute for each user on each Domain
> Controller. For k = 0 To Ubound(arrstrDCs)
> strBase = "<LDAP://" & arrstrDCs(k) & "/" & strDNSDomain & ">"
> strFilter = "(&(objectCategory=person)(objectClass=user))"
> strAttributes = "distinguishedName,lastLogon"
> strQuery = strBase & ";" & strFilter & ";" & strAttributes _
> & ";subtree"
> objCommand.CommandText = strQuery
> On Error Resume Next
> Set objRecordSet = objCommand.Execute
> If Err.Number <> 0 Then
> On Error GoTo 0
> Wscript.Echo "El Controlador de Dominio no esta Habilitado : " &
> arrstrDCs(k)
> Else
> On Error GoTo 0
> Do Until objRecordSet.EOF
> strDN = objRecordSet.Fields("distinguishedName")
> lngDate = objRecordSet.Fields("lastLogon")
> On Error Resume Next
> Set objDate = lngDate
> If Err.Number <> 0 Then
> On Error GoTo 0
> dtmDate = #1/1/1601#
> Else
> On Error GoTo 0
> lngHigh = objDate.HighPart
> lngLow = objDate.LowPart
> If lngLow < 0 Then
> lngHigh = lngHigh + 1
> End If
> If (lngHigh = 0) And (lngLow = 0 ) Then
> dtmDate = #1/1/1601#
> Else
> dtmDate = #1/1/1601# + (((lngHigh * (2 ^ 32)) _
> + lngLow)/600000000 - lngBias)/1440
> End If
> End If
> If objList.Exists(strDN) Then
> If dtmDate > objList(strDN) Then
> objList(strDN) = dtmDate
> End If
> Else
> objList.Add strDN, dtmDate
> End If
> objRecordSet.MoveNext
> Loop
> End If
> Next
>
> ' ABRE FICHERO PARA GUARDAR LOS DATOS DE LOS USUARIOS
> ' DEBE EXISTIR LA CARPETA C:\TEMP PARA SU CORRECTO FUNCIONAMIENTO
> Dim objFileSystem, objOutputFile
> Dim strOutputFile
>
> ' generate a filename base on the script name
> strOutputFile = "C:\temp\usuariosAD.txt"
>
> Set objFileSystem = CreateObject("Scripting.fileSystemObject")
> Set objOutputFile = objFileSystem.CreateTextFile(strOutputFile, TRUE)
>
> ' Output latest lastLogon date for each user.
> For Each strUser In objList
> 'Wscript.Echo strUser & " ; " & objList(strUser)
> objOutputFile.WriteLine(strUser & " ; " & objList(strUser))
> Next
>
> ' Clean up.
> objConnection.Close
> objOutputFile.Close
> Set objFileSystem = Nothing
> Set objRootDSE = Nothing
> Set objConnection = Nothing
> Set objCommand = Nothing
> Set objRecordSet = Nothing
> Set objDC = Nothing
> Set objDate = Nothing
> Set objList = Nothing
> Set objShell = Nothing
>
>
>
> Pablo Stamati ha escrito:
>
>> Si, tambien lo podés hacer con una aplicación.
>> Se llama RealLastLogonen www.tools4ever.com
>>
>> Es muy util para estos reportes, porque si tenes mas de un Domain
>> Controller, chequea el último logon en cada uno, y te reporta el mas
>> reciente.
>>
>> Espero que te haya servido
>> Saludos
>> "nannyta" wrote in message
>> news:
>> Hola, una pregunta...
>>
>>
>> Alguien sabe como puedo averiguar qué usuarios (ya creados) no han
>> iniciado sesion en X cantidad de tiempo?
>>
>>
>> Por ej.
>>
>> Quiero saber que usuarios llevan mas de 6 meses sin iniciar sesion.
>>
>>
>> Con el Visor de sucesos (Seguridad) se me peta el archivo al tratar
>> de abrirlo, ya que pesa 50 megas x_X
>>
>> ayuda!
>>
>>
>> Graciaaaaaaaaaaaaaaaaaaas :D
>>
>> nanny.
Respuesta Responder a este mensaje
#7 Fernando Reyes [MS MVP]
13/10/2006 - 16:53 | Informe spam
Si desde una ventana de comandos (cmd.exe) lanzas el script con cscript
(cscript //nologo LastLogon.vbs > "C:\temp\usuariosAD.txt") no se debe
producir ese comportamiento (a mí desde luego no me lo hace, escribe los
resultados en el fichero y no abre ningún msgbox). Para que se produzca eso
se debe lanzar wcript (poniendo wscript en lugar de cscript sólo con:
LastLogon.vbs > "C:\temp\usuariosAD.txt"; esto es así pues wscript es el
programa predeterminado para ejecutar vbs)

Un saludo
Fernando Reyes [MS MVP]
MCSE Windows 2000 / 2003
MCSA Windows Server 2003
http://freyes.svetlian.com
http://www.bloglines.com/blog/urpiano

(Tírate de la moto si quieres escribirme)



Y fue nannyta () quien en el mensaje
, planeando sobre su
teclado, hizo un picado y tecleó:

Fernando, esa linea la agregué yo :P
y el programa lo ejecute desde la ventana de comandos, y me abria
popups :)
ahora ya no me abre popups, sino que me los deja en usuariosAD.txt ;)

Saludos.

Adriana.



Fernando Reyes [MS MVP] ha escrito:

Bastaba con que lo ejecutaras con cscript, desde una ventana de
comandos, en lugar de wscript, que es usado al hacer doble click
sobre el script, para que se volcara a una ventana de comandos; si
utilizas redirección de salida puedes crear el fichero de texto; es
decir, si lo hibieses lanzado así (tal y como indica Richard Mueller
en el enlace que te puse):

cscript //nologo LastLogon.vbs > "C:\temp\usuariosAD.txt"
Un saludo
Fernando Reyes [MS MVP]
MCSE Windows 2000 / 2003
MCSA Windows Server 2003
http://freyes.svetlian.com
http://www.bloglines.com/blog/urpiano

(Quítate el mono si quieres escribirme)



Y fue nannyta () quien en el mensaje
, planeando
sobre su teclado, hizo un picado y tecleó:

Fernando y Pablo:

Muchas gracias por la ayuda, bajé el script que me indicó Fernando y
lo modifiqué, para que así, en vez de enviar un POPUP indicando la
fecha en que cada usuario hizo su logon por ultima vez, te lo envíe
a un TXT. y así se puede editar.

Les dejo aqui el script modificado, solo lo tienen que guardar como
.vbs y al ejecutarlo, en c:/temp (deben crear esa carpeta) se creará
un archivo txt con todos los usuarios del AD y las respectivas
fechas de Logon.

GRACIAS!!!!
' Copyright (c) 2002 Richard L. Mueller
' Hilltop Lab web site - http://www.rlmueller.net
' Version 1.0 - December 7, 2002
' Version 1.1 - January 17, 2003 - Account for null value for
lastLogon.
' Version 1.2 - January 23, 2003 - Account for DC not available.
' Version 1.3 - February 3, 2003 - Retrieve users but not contacts.
' Version 1.4 - February 19, 2003 - Standardize Hungarian notation.
' Version 1.5 - March 11, 2003 - Remove SearchScope property.
' Version 1.6 - May 9, 2003 - Account for error in IADsLargeInteger
' property methods HighPart and LowPart.
' Version 1.7 - January 25, 2004 - Modify error trapping.
' Version 1.8 - October 13, 2006 - La modificacion que se hace es
cambiar los popap por un txt.
'
' Because the lastLogon attribute is not replicated, every Domain
' Controller in the domain must be queried to find the latest
lastLogon ' date for each user. The lastest date found is kept in a
dictionary ' object. The program first uses ADO to search the domain
for all Domain
' Controllers. The AdsPath of each Domain Controller is saved in an
' array. Then, for each Domain Controller, ADO is used to search the
' copy of Active Directory on that Domain Controller for all user
' objects and return the lastLogon attribute. The lastLogon
attribute is
' a 64-bit number representing the number of 100 nanosecond
intervals ' since 12:00 am January 1, 1601. This value is converted
to a date. The
' last logon date is in UTC (Coordinated Univeral Time). It must be
' adjusted by the Time Zone bias in the machine registry to convert
to ' local time.
'
' You have a royalty-free right to use, modify, reproduce, and
' distribute this script file in any way you find useful, provided
that ' you agree that the copyright owner above has no warranty,
obligations,
' or liability for such use.

Option Explicit

Dim objRootDSE, strConfig, objConnection, objCommand, strQuery
Dim objRecordSet, objDC
Dim strDNSDomain, objShell, lngBiasKey, lngBias, k, arrstrDCs()
Dim strDN, dtmDate, objDate, lngDate, objList, strUser
Dim strBase, strFilter, strAttributes, lngHigh, lngLow

' Use a dictionary object to track latest lastLogon for each user.
Set objList = CreateObject("Scripting.Dictionary")
objList.CompareMode = vbTextCompare

' Obtain local Time Zone bias from machine registry.
Set objShell = CreateObject("Wscript.Shell")
lngBiasKey >>> objShell.RegRead("HKLM\System\CurrentControlSet\Control\" _
& "TimeZoneInformation\ActiveTimeBias")
If UCase(TypeName(lngBiasKey)) = "LONG" Then
lngBias = lngBiasKey
ElseIf UCase(TypeName(lngBiasKey)) = "VARIANT()" Then
lngBias = 0
For k = 0 To UBound(lngBiasKey)
lngBias = lngBias + (lngBiasKey(k) * 256^k)
Next
End If

' Determine configuration context and DNS domain from RootDSE
object. Set objRootDSE = GetObject("LDAP://RootDSE")
strConfig = objRootDSE.Get("configurationNamingContext")
strDNSDomain = objRootDSE.Get("defaultNamingContext")

' Use ADO to search Active Directory for ObjectClass nTDSDSA.
' This will identify all Domain Controllers.
Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection

strBase = "<LDAP://" & strConfig & ">"
strFilter = "(objectClass=nTDSDSA)"
strAttributes = "AdsPath"
strQuery = strBase & ";" & strFilter & ";" & strAttributes &
";subtree"


objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 100
objCommand.Properties("Timeout") = 60
objCommand.Properties("Cache Results") = False

Set objRecordSet = objCommand.Execute

' Enumerate parent objects of class nTDSDSA. Save Domain Controller
' AdsPaths in dynamic array arrstrDCs.
k = 0
Do Until objRecordSet.EOF
Set objDC = _
GetObject(GetObject(objRecordSet.Fields("AdsPath")).Parent)
ReDim Preserve arrstrDCs(k)
arrstrDCs(k) = objDC.DNSHostName
k = k + 1
objRecordSet.MoveNext
Loop

' Retrieve lastLogon attribute for each user on each Domain
Controller. For k = 0 To Ubound(arrstrDCs)
strBase = "<LDAP://" & arrstrDCs(k) & "/" & strDNSDomain & ">"
strFilter = "(&(objectCategory=person)(objectClass=user))"
strAttributes = "distinguishedName,lastLogon"
strQuery = strBase & ";" & strFilter & ";" & strAttributes _
& ";subtree"
objCommand.CommandText = strQuery
On Error Resume Next
Set objRecordSet = objCommand.Execute
If Err.Number <> 0 Then
On Error GoTo 0
Wscript.Echo "El Controlador de Dominio no esta Habilitado : " &
arrstrDCs(k)
Else
On Error GoTo 0
Do Until objRecordSet.EOF
strDN = objRecordSet.Fields("distinguishedName")
lngDate = objRecordSet.Fields("lastLogon")
On Error Resume Next
Set objDate = lngDate
If Err.Number <> 0 Then
On Error GoTo 0
dtmDate = #1/1/1601#
Else
On Error GoTo 0
lngHigh = objDate.HighPart
lngLow = objDate.LowPart
If lngLow < 0 Then
lngHigh = lngHigh + 1
End If
If (lngHigh = 0) And (lngLow = 0 ) Then
dtmDate = #1/1/1601#
Else
dtmDate = #1/1/1601# + (((lngHigh * (2 ^ 32)) _
+ lngLow)/600000000 - lngBias)/1440
End If
End If
If objList.Exists(strDN) Then
If dtmDate > objList(strDN) Then
objList(strDN) = dtmDate
End If
Else
objList.Add strDN, dtmDate
End If
objRecordSet.MoveNext
Loop
End If
Next

' ABRE FICHERO PARA GUARDAR LOS DATOS DE LOS USUARIOS
' DEBE EXISTIR LA CARPETA C:\TEMP PARA SU CORRECTO FUNCIONAMIENTO
Dim objFileSystem, objOutputFile
Dim strOutputFile

' generate a filename base on the script name
strOutputFile = "C:\temp\usuariosAD.txt"

Set objFileSystem = CreateObject("Scripting.fileSystemObject")
Set objOutputFile = objFileSystem.CreateTextFile(strOutputFile,
TRUE)

' Output latest lastLogon date for each user.
For Each strUser In objList
'Wscript.Echo strUser & " ; " & objList(strUser)
objOutputFile.WriteLine(strUser & " ; " & objList(strUser))
Next

' Clean up.
objConnection.Close
objOutputFile.Close
Set objFileSystem = Nothing
Set objRootDSE = Nothing
Set objConnection = Nothing
Set objCommand = Nothing
Set objRecordSet = Nothing
Set objDC = Nothing
Set objDate = Nothing
Set objList = Nothing
Set objShell = Nothing



Pablo Stamati ha escrito:

Si, tambien lo podés hacer con una aplicación.
Se llama RealLastLogonen www.tools4ever.com

Es muy util para estos reportes, porque si tenes mas de un Domain
Controller, chequea el último logon en cada uno, y te reporta el
mas reciente.

Espero que te haya servido
Saludos
"nannyta" wrote in message
news:
Hola, una pregunta...


Alguien sabe como puedo averiguar qué usuarios (ya creados) no han
iniciado sesion en X cantidad de tiempo?


Por ej.

Quiero saber que usuarios llevan mas de 6 meses sin iniciar sesion.


Con el Visor de sucesos (Seguridad) se me peta el archivo al tratar
de abrirlo, ya que pesa 50 megas x_X

ayuda!


Graciaaaaaaaaaaaaaaaaaaas :D

nanny.
email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una pregunta AnteriorRespuesta Tengo una respuesta
Search Busqueda sugerida