
17/12/2002, 12:38
|
 | | | Fecha de Ingreso: diciembre-2002 Ubicación: Chapinlandia :-D
Mensajes: 725
Antigüedad: 22 años, 4 meses Puntos: 11 | |
intenta ver con este codigo
Dim cont As IADsContainer
'Example: Enumerating all local users on member server or workstation
'''''''''''''''''''''''''''''''''''''''
'Parse the arguments
'''''''''''''''''''''''''''''''''''''''
sComputer = InputBox("This script lists the users on a member server or workstation." & vbCrLf & vbCrLf & "Specify the computer name:")
If sComputer = "" Then
Exit Sub
End If
'''''''''''''''''''''''''''''''''''''''
'Bind to the computer
'''''''''''''''''''''''''''''''''''''''
'Note that this sample uses the logged-on user's context
'To specify a user account other than the user account under
'which your application is running, use IADsOpenDSObject.
Set cont = GetObject("WinNT://" & sComputer & ",computer")
If (Err.Number <> 0) Then
BailOnFailure Err.Number, "on GetObject method"
End If
'''''''''''''''''''''''''''''''''''''''
'Filter to view only user objects
'''''''''''''''''''''''''''''''''''''''
cont.Filter = Array("User")
If (Err.Number <> 0) Then
BailOnFailure Err.Number, "on IADsContainer::Filter method"
End If
strText = ""
intIndex = 0
intNumDisplay = 0
cmember = 0
'Maximum number of users to list on a msgbox.
MAX_DISPLAY = 20
'''''''''''''''''''''''''''''''''''''''
'Get each user
'''''''''''''''''''''''''''''''''''''''
For Each user In cont
intIndex = intIndex + 1
'Get the name
strText = strText & vbCrLf & Right(" " & intIndex, 4) & " " & user.Name
intNumDisplay = intNumDisplay + 1
'Display in msgbox if there are MAX_DISPLAY users to display
If intNumDisplay >= MAX_DISPLAY Then
Call show_users(strText, sComputer)
strText = ""
intNumDisplay = 0
End If
'Reset the count of members within the current group
cmember = 0
Next
Call show_users(strText, sComputer)
'''''''''''''''''''''''''''''''''''''''
'Display subroutines
'''''''''''''''''''''''''''''''''''''''
Sub show_users(strText, strName)
MsgBox strText, vbInformation, "Users on " & strName
End Sub
Sub BailOnFailure(ErrNum, ErrText) strText = "Error 0x" & Hex(ErrNum) & " " & ErrText
MsgBox strText, vbInformation, "ADSI Error"
WScript.Quit
End Sub |