Bonjour,Je ne comprends pas l'intérêt du deuxième script par rapport au
premierou ne comprends pas ce script tout simplement.------Script
1----------Dim WshNetworkSet WshNetwork =
WScript.CreateObject("WScript.Network")if isMember("Domain Admins")
ThenWshNetwork.MapNetworkDrive "I:" , "\\server\share"end if------Script
2---------Option Explicit ' Force explicit declarations
'
' Variables
'
Dim WSHNetwork
Dim FSO
Dim strUserName ' Current user
Dim strUserDomain ' Current User's domain name
Dim ObjGroupDict ' Dictionary of groups to which the user belongs
Set WSHNetwork = WScript.CreateObject("WScript.Network")
Set FSO = CreateObject("Scripting.FileSystemObject")
'
' Wait until the user is really logged in...
'
strUserName = ""
While strUserName = ""
WScript.Sleep 100 ' 1/10 th of a second
strUserName = WSHNetwork.UserName
Wend
strUserDomain = WSHNetwork.UserDomain
' Read the user's account "Member Of" tab info across the network
' once into a dictionary object.
Set ObjGroupDict = CreateMemberOfObject(strUserDomain, strUserName)
If MemberOf(ObjGroupDict, "Domain Admins") Then
wscript.echo "Is a member of Domain Admins."
'REM this line to Map Network Drives
Else
wscript.echo "Is NOT a member of Domain Admins"
End If
Function MemberOf(ObjDict, strKey)
' Given a Dictionary object containing groups to which the user
' is a member of and a group name, then returns True if the group
' is in the Dictionary else return False.
'
' Inputs:
' strDict - Input, Name of a Dictionary object
' strKey - Input, Value being searched for in
' the Dictionary object
' Sample Usage:
'
' If MemberOf(ObjGroupDict, "DOMAIN ADMINS") Then
' wscript.echo "Is a member of Domain Admins."
' End If
'
'
MemberOf = CBool(ObjGroupDict.Exists(strKey))
End Function
Function CreateMemberOfObject(strDomain, strUserName)
' Given a domain name and username, returns a Dictionary
' object of groups to which the user is a member of.
'
' Inputs:
'
' strDomain - Input, NT Domain name
' strUserName - Input, NT username
'
Dim objUser, objGroup
Set CreateMemberOfObject = CreateObject("Scripting.Dictionary")
CreateMemberOfObject.CompareMode = vbTextCompare
Set objUser = GetObject("WinNT://" _
& strDomain & "/" _
& strUserName & ",user")
For Each objGroup In objUser.Groups
CreateMemberOfObject.Add objGroup.Name, "-"
Next
Set objUser = Nothing
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Hervé
toutes mes excuses, c'était le bazar Je reprend:
Bonjour,Je ne comprends pas l'intérêt du deuxième script par rapport au premierou ne comprends pas ce script tout simplement
Script 1----------
Dim WshNetworkSet WshNetwork WScript.CreateObject("WScript.Network")if isMember("Domain Admins") ThenWshNetwork.MapNetworkDrive "I:" , "servershare"endif
Script 2---------
Option Explicit ' Force explicit declarations ' ' Variables ' Dim WSHNetwork Dim FSO Dim strUserName ' Current user Dim strUserDomain ' Current User's domain name Dim ObjGroupDict ' Dictionary of groups to which the user belongs
Set WSHNetwork = WScript.CreateObject("WScript.Network") Set FSO = CreateObject("Scripting.FileSystemObject") ' ' Wait until the user is really logged in... ' strUserName = "" While strUserName = "" WScript.Sleep 100 ' 1/10 th of a second strUserName = WSHNetwork.UserName Wend strUserDomain = WSHNetwork.UserDomain
' Read the user's account "Member Of" tab info across the network ' once into a dictionary object.
Set ObjGroupDict = CreateMemberOfObject(strUserDomain, strUserName) If MemberOf(ObjGroupDict, "Domain Admins") Then wscript.echo "Is a member of Domain Admins." 'REM this line to Map Network Drives
Else wscript.echo "Is NOT a member of Domain Admins" End If
Function MemberOf(ObjDict, strKey) ' Given a Dictionary object containing groups to which the user ' is a member of and a group name, then returns True if the group ' is in the Dictionary else return False. ' ' Inputs: ' strDict - Input, Name of a Dictionary object ' strKey - Input, Value being searched for in ' the Dictionary object ' Sample Usage: ' ' If MemberOf(ObjGroupDict, "DOMAIN ADMINS") Then ' wscript.echo "Is a member of Domain Admins." ' End If ' ' MemberOf = CBool(ObjGroupDict.Exists(strKey))
End Function
Function CreateMemberOfObject(strDomain, strUserName) ' Given a domain name and username, returns a Dictionary ' object of groups to which the user is a member of. ' ' Inputs: ' ' strDomain - Input, NT Domain name ' strUserName - Input, NT username ' Dim objUser, objGroup
Set CreateMemberOfObject = CreateObject("Scripting.Dictionary") CreateMemberOfObject.CompareMode = vbTextCompare Set objUser = GetObject("WinNT://" _ & strDomain & "/" _ & strUserName & ",user") For Each objGroup In objUser.Groups CreateMemberOfObject.Add objGroup.Name, "-" Next Set objUser = Nothing
End Function
toutes mes excuses, c'était le bazar
Je reprend:
Bonjour,Je ne comprends pas l'intérêt du deuxième script par rapport au
premierou ne comprends pas ce script tout simplement
Script 1----------
Dim WshNetworkSet WshNetwork WScript.CreateObject("WScript.Network")if isMember("Domain Admins")
ThenWshNetwork.MapNetworkDrive "I:" , "\servershare"endif
Script 2---------
Option Explicit ' Force explicit declarations
'
' Variables
'
Dim WSHNetwork
Dim FSO
Dim strUserName ' Current user
Dim strUserDomain ' Current User's domain name
Dim ObjGroupDict ' Dictionary of groups to which the user belongs
Set WSHNetwork = WScript.CreateObject("WScript.Network")
Set FSO = CreateObject("Scripting.FileSystemObject")
'
' Wait until the user is really logged in...
'
strUserName = ""
While strUserName = ""
WScript.Sleep 100 ' 1/10 th of a second
strUserName = WSHNetwork.UserName
Wend
strUserDomain = WSHNetwork.UserDomain
' Read the user's account "Member Of" tab info across the network
' once into a dictionary object.
Set ObjGroupDict = CreateMemberOfObject(strUserDomain, strUserName)
If MemberOf(ObjGroupDict, "Domain Admins") Then
wscript.echo "Is a member of Domain Admins."
'REM this line to Map Network Drives
Else
wscript.echo "Is NOT a member of Domain Admins"
End If
Function MemberOf(ObjDict, strKey)
' Given a Dictionary object containing groups to which the user
' is a member of and a group name, then returns True if the group
' is in the Dictionary else return False.
'
' Inputs:
' strDict - Input, Name of a Dictionary object
' strKey - Input, Value being searched for in
' the Dictionary object
' Sample Usage:
'
' If MemberOf(ObjGroupDict, "DOMAIN ADMINS") Then
' wscript.echo "Is a member of Domain Admins."
' End If
'
'
MemberOf = CBool(ObjGroupDict.Exists(strKey))
End Function
Function CreateMemberOfObject(strDomain, strUserName)
' Given a domain name and username, returns a Dictionary
' object of groups to which the user is a member of.
'
' Inputs:
'
' strDomain - Input, NT Domain name
' strUserName - Input, NT username
'
Dim objUser, objGroup
Set CreateMemberOfObject = CreateObject("Scripting.Dictionary")
CreateMemberOfObject.CompareMode = vbTextCompare
Set objUser = GetObject("WinNT://" _
& strDomain & "/" _
& strUserName & ",user")
For Each objGroup In objUser.Groups
CreateMemberOfObject.Add objGroup.Name, "-"
Next
Set objUser = Nothing
Bonjour,Je ne comprends pas l'intérêt du deuxième script par rapport au premierou ne comprends pas ce script tout simplement
Script 1----------
Dim WshNetworkSet WshNetwork WScript.CreateObject("WScript.Network")if isMember("Domain Admins") ThenWshNetwork.MapNetworkDrive "I:" , "servershare"endif
Script 2---------
Option Explicit ' Force explicit declarations ' ' Variables ' Dim WSHNetwork Dim FSO Dim strUserName ' Current user Dim strUserDomain ' Current User's domain name Dim ObjGroupDict ' Dictionary of groups to which the user belongs
Set WSHNetwork = WScript.CreateObject("WScript.Network") Set FSO = CreateObject("Scripting.FileSystemObject") ' ' Wait until the user is really logged in... ' strUserName = "" While strUserName = "" WScript.Sleep 100 ' 1/10 th of a second strUserName = WSHNetwork.UserName Wend strUserDomain = WSHNetwork.UserDomain
' Read the user's account "Member Of" tab info across the network ' once into a dictionary object.
Set ObjGroupDict = CreateMemberOfObject(strUserDomain, strUserName) If MemberOf(ObjGroupDict, "Domain Admins") Then wscript.echo "Is a member of Domain Admins." 'REM this line to Map Network Drives
Else wscript.echo "Is NOT a member of Domain Admins" End If
Function MemberOf(ObjDict, strKey) ' Given a Dictionary object containing groups to which the user ' is a member of and a group name, then returns True if the group ' is in the Dictionary else return False. ' ' Inputs: ' strDict - Input, Name of a Dictionary object ' strKey - Input, Value being searched for in ' the Dictionary object ' Sample Usage: ' ' If MemberOf(ObjGroupDict, "DOMAIN ADMINS") Then ' wscript.echo "Is a member of Domain Admins." ' End If ' ' MemberOf = CBool(ObjGroupDict.Exists(strKey))
End Function
Function CreateMemberOfObject(strDomain, strUserName) ' Given a domain name and username, returns a Dictionary ' object of groups to which the user is a member of. ' ' Inputs: ' ' strDomain - Input, NT Domain name ' strUserName - Input, NT username ' Dim objUser, objGroup
Set CreateMemberOfObject = CreateObject("Scripting.Dictionary") CreateMemberOfObject.CompareMode = vbTextCompare Set objUser = GetObject("WinNT://" _ & strDomain & "/" _ & strUserName & ",user") For Each objGroup In objUser.Groups CreateMemberOfObject.Add objGroup.Name, "-" Next Set objUser = Nothing