I am trying to write a script to create subnets that are associated with AD
sites. The example below has just one being created, but I'll add reading
from a text file once this one works. "This simply returns an invalid dn
syntax has been specified."
Thanks in advance for any suggestions.
strSubnetRDN = "CN=172.16.43.96/26"
strSiteObjectRDN = "CN=CHFS-ColdHarbor"
strDescription = "CHFS Subnet"
strLocation = "CHFS-ColdHarbor"
'************************************************************************************************************************
'
'Set objRootDSE = GetObject("LDAP:RootDSE")
'
'strConfigurationNC = objRootDSE.Get("configurationNamingContext")
'wscript.echo(strConfigurationNC)
'
'************************************************************************************************************************
' Determine the Site Object Distinguished Name
'************************************************************************************************************************
'Note: I think the problem is with this line:
'strSiteObjectDN = strSiteObjectRDN &
",CN=Subnets,CN=Sites,CN=Configuration,DC=ds,DC=ky,DC=gov," '&
strConfigurationNC
'
' 1) First one is that the CHFS-ColdHarbor is not in Subnet, but directly
under Sites. so remove CN=Subnets
' 2) There is a comma after gov in the string. remove it too. You now
should have the following line:
'************************************************************************************************************************
strSiteObjectDN = strSiteObjectRDN &
",CN=Sites,CN=Configuration,DC=DS,DC=KY,DC=GOV" '& strConfigurationNC
wscript.echo(strConfigurationDN)
'************************************************************************************************************************
'************************************************************************************************************************
' Determine the Subnet Container
'************************************************************************************************************************
strSubnetsContainer =
"LDAP://CN=Subnets,CN=Sites,CN=Configuration,DC=DS,DC=KY,DC=GOV" '&
strConfigurationNC
wscript.echo(strSubnetsContainer)
Set objSubnetsContainer = GetObject(strSubnetsContainer)
'************************************************************************************************************************
'************************************************************************************************************************
'Create and set the object properties.
'************************************************************************************************************************
Set objSubnet = objSubnetsContainer.Create("subnet", strSubnetRDN)
objSubnet.Put "siteObject", strSiteObjectDN
'objSubnet.Put "description", strDescription
'objSubnet.Put "location", strLocation
wscript.echo ("Subnet RDN = " & strSubnetRDN)
wscript.echo ("Site Obj RDN = " & strSiteObjectRDN)
wscript.echo ("Site Obj DN = " & strSiteObjectDN)
wscript.echo ("Subnet Container = " & strSubnetsContainer)
wscript.echo ("Desc = " & strDescription)
objSubnet.SetInfo