voici la réponse :
Bonjour :D,
Ma GPO fonctionne du feux de Dieu!!
Que j'explique en détail:
Ce script recherche l'OU de l'utilisateur, la liste des lecteurs partagés dans cette OU et enfin il les mappe.
Code: Select all
Dim WshShell
Dim objNet
Dim objRootDSE
Dim Tab
Dim DN
Dim i
Dim strComputer
DN = ""
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objNet = WScript.CreateObject("WScript.Network")' create network object for vars
Set objRootDSE = GetObject("LDAP://rootDSE")' bind to the rootDSE for portability
strADsConfPath = "LDAP://" & objRootDSE.Get("configurationNamingContext")' bind to configuration to get Domain Controllers later
strRootDSE = objRootDSE.Get("defaultNamingContext")' bind to the defaultContext for portability
strUserName = UCase(objNet.UserName)' pull user name from environment variable
Tab = Split(GetDNUser(strUserName,"person"),",")
For i=1 to UBound(Tab)
If i = Ubound(Tab) Then
DN = DN + Tab(i)
Else
DN = DN + Tab(i) + ","
End If
Next
'MsgBox DN
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = "Select Name, unCName, ManagedBy from " _
& "'LDAP://"&DN&"' where objectClass='volume'"
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
'Wscript.Echo "Share Name: " & objRecordSet.Fields("Name").Value
msgbox objRecordSet.Fields("Name").Value
msgbox objRecordSet.Fields("uNCName").Value
Dim oNet
Set oNet = CreateObject("Wscript.Network")
oNet.MapNetworkDrive objRecordSet.Fields("Name").Value, objRecordSet.Fields("uNCName").Value
objRecordSet.MoveNext
Loop
Function GetDNUser(param1,param2)
Set objDSE = GetObject("LDAP://rootDSE")
ON ERROR RESUME NEXT
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = "SELECT distinguishedName, Sn " & "FROM 'LDAP://" & objDSE.Get("defaultNamingContext") & "' " & "WHERE objectCategory='" & param2 & "' AND sAMAccountName='" & param1 & "' " & "ORDER BY sAMAccountName"
Set objRecordSet = objCommand.Execute
GetDNUser = objRecordSet.Fields("distinguishedName")
objConnection.Close
if err.number <> 0 then
msgbox "ERREUR: le nom renseigné n'existe pas dans l'AD.",16,Wscript.ScriptName & " " & version
ERR.CLEAR
wscript.quit
end if
End Function
MsgBox "Mappage effectué"
-Dans mon AD, je fais un nouveau partage sur une OU. Dans la fenetre qui s'ouvre dans le champs "name" je renseigne le nom du lecteur que je souhaite partager (L:). Dans le champs "Network path" renseigner le chemin du lecteur (\\monserveur\share). renouveler l'opération autant de fois que vous avez de lecteur à partager.
-Dans GPMC clic droit sur l'OU, create and link a GPO here. Donner un nom à votre nouvelle GPO.
-Clic droit sur la nouvelle GPO, puis sur User Configuration,Windows Setting, Script(Logon/Logoff), Logon,Add.
-Dans la fenetre qui s'ouvre dans le champs script name cliquer sur Browse et rajouter le script (celui là haut) que vous aurez préalablement copier dans le fichier script de votre serveur (C:,WINDOWS,SYSVOL,sysvol, mon domaine,policies,{9F09....},user, script, logon).
-Dans l'AD placé les utilisateurs concernés dans l'OU.
-Faire un gpupdate dans la console du serveur et voilà vos lecteurs sont mappés hihihi trop contente je suis :D