Bonjour,

Je suis débutant dans le monde du script. J'essaye d'écrire un script pour créer des subnets AD dans Sites et Services Active Directory, depuis un fichier csv.
Comme je suis débutant je ne peux pas démarrer d'une page blanche donc j'ai pris des morceaux de script sur le net. Ma principal source sont les technet de microsoft.
Mon script me paraît correcte. Mais quand je l’exécute avec un user domain admin, je me retrouve avec l'erreur suivante "A constraint violation occured" code "8007202F"
Merci de m'éclairer sur l'erreur que j'ai du commettre

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Dim strSiteRDN, strSiteLinkRDN, strSiteLinkType
Dim objRootDSE, strConfigurationNC, strSubnetsContainer
Dim objSitesContainer, objSite, strSiteLinkPath, objSiteLink
Dim strFile, objFSO, objFile, strLine, arrValues
 
Const ADS_PROPERTY_APPEND = 3
Const ForReading = 1
 
' Specify text file of comma delimited parameters.
strFile = "c:\Script\SubnetInfo.csv"
 
' Open the file for reading.
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strFile, ForReading)
 
' Bind to Sites container. Do this just once.
Set objRootDSE = GetObject("LDAP://RootDSE")
 
strConfigurationNC = objRootDSE.Get("configurationNamingContext")
strSiteObjectDN = strSiteObjectRDN & ",cn=Sites," & strConfigurationNC
strSubnetsContainer = "LDAP://cn=Subnets,cn=Sites" & strConfigurationNC
 
Set objSubnetsContainer = GetObject("LDAP://cn=Subnets,cn=Sites,cn=configuration,DC=mondomaine,DC=net")
 
' Read the text file.
Do Until objFile.AtEndOfStream
    strLine = Trim(objFile.ReadLine)
    strLine = Replace(strLine, """", "")
    arrValues = Split(strLine, ",")
 
  If (UBound(arrValues) = 3) Then
    strSubnetRDN = arrValues(0)
    strSiteObjectRDN = arrValues(1)
    strDescription = arrValues(2)
	strLocation = arrValues (3)
 
    ' Create the Subnet object.
  Set objSubnet = objSubnetsContainer.Create("subnet", strSubnetRDN)
	objSubnet.Put "siteObject", strSiteObjectDN
	objSubnet.Put "description", strDescription
	objSubnet.Put "location", strLocation
	objSubnet.SetInfo
 
 
 
  Else
    Wscript.Echo "Invalid line: " & strLine
  End If
 
Loop
 
' Clean up.
objFile.Close