PUB

  Sommaire
Le registre de Windows
Les API Windows
Les fichiers de stratégie
Les fichiers INF
Les lignes de commandes
Les scripts Windows
VBS
WSH
ADSI (WinNT Provider)
Namespace
Domain
User
Group
IADs
Get
GetEx
GetInfo
GetInfoEx
Put
PutEx
SetInfo
IADsGroup
Add
IsMember
Members
Remove
IADsPropertyList
GetPropertyItem
Item
Next
PurgePropertyList
PutPropertyItem
Reset
ResetPropertyItem
Skip
Computer
LocalGroup
PrintJob
PrintQueue
Service
FileService
FileShare
Resource
Session
WMI
ScriptCenter
Les erreurs Windows
Les trucs et astuces
Télécharger

  Publicité

  Les scripts Windows

Hiérarchie des objets de classe WinNT :

Objet de classe Description
Namespace Récipient de plus haut niveau.
Domain Représente un domaine.
User Représente un compte utilisateur du domaine.
Group Représente un groupe global du domaine.
Computer Représente un ordinateur (serveur ou station de travail).
User Représente un compte utilisateur local.
LocalGroup Représente un groupe local.
PrintJob Représente un travail d'impression.
PrintQueue Représente une file d'impression.
Service Représente une application qui s'exécute en tant que service.
FileService Représente le service qui permet d'accèder au système de fichiers.
FileShare Représente un partage de fichiers.
Resource Représente une ressource.
Session Représente une session.

Remarque :

L'exemple ci-dessous illustre l'utilisation de l'objet Group :

' Example on how to determine if the current user is member of
'Administrators or Domain Admins


Dim oNet
Dim oShell
Dim oLocalGrp
Dim oDomGrp
Dim oDom
Dim sUsername
Dim sWSName
Dim sDomain
Dim bLocalAdmin
Dim bAdminDirectlyAdded

'Init as nonadmin
bLocalAdmin=False
bAdminDirectlyAdded=False

Set oShell=CreateObject("WScript.Shell")
Set oNet=CreateObject("WScript.Network")
'Get the username and Workstationname from the Core Network object

sUsername=oNet.UserName
sWSName=oNet.ComputerName
sDomain=oNet.UserDomain

'Get the local administrator group (ADSI)
Set oLocalGrp = GetObject("WinNT://" & sDomain & "/" & sWSName & "/Administrateurs,group")

'Check if the username is added directly to the local admin group
For Each LocalObj in oLocalGrp.Members
  If LCase(sUserName) = LCase(LocalObj.Name) Then bLocalAdmin=True
Next

'Check if the username is added directly to the GLOBAL admin group
Set oDomGrp = GetObject("WinNT://" & sDomain & "/Admins du domaine,group")

'Check if the username is added directly to the GLOBAL admin group
For Each GlobalObj in oDomGrp.Members
    If LCase(sUserName) = LCase(GlobalObj.Name) Then
      bLocalAdmin=True
      bAdminDirectlyAdded=True
    End If
  Next

If bLocalAdmin=True Then
 	oShell.Popup sUserName & " is member of the local group 'Administrators' on Workstation '" & sWSName & "'"
else
	oShell.Popup sUserName & " is not local Admin"
End if

If bAdminDirectlyAdded=True Then
    oShell.Popup sUserName & " is member of the global group 'Domain Admins' on Domain '" & sDomain & "'"
End if