Location: List Archives

List Archives

This forum is an archive of all posts to our mailing list over the past few years.  The forum is set read only therefore to contribute you will need to join our list community.  See more info about this here.

 

When subscribed to the list you should use your standard email client to send your posts to ActiveDir@mail.activedir.org.

List Archives

Subject: [ActiveDir] VBScript + LDAP path + forward slash character = bad
Prev Next
You are not authorized to post a reply.

AuthorMessages
joe1User is Offline

Posts:5

04/17/2008 9:38 AM  
<longshot mode>

Hi all, I'm attempting to write a bit a vbscript to *edit* subnet
objects in our AD. I'm struggling to bind to a subnet objectΏ], and
cannot find any sample code to do this.

My code is failing because the LDAP path I'm using to bind to the subnet
contains a forward slash "/", which is not legal in an LDAP path.
Anyone know how to get around this, as its part of the distinguished
names of the subnet objects.

Thanks
Joe

Ώ] Example:
CN=192.168.0.0/24,cn=Subnets,CN=Sites,CN=Configuration,DC=mydomain,DC=co
m



hcolemanUser is Offline

Posts:31

04/17/2008 9:58 AM  
Did you try escaping the forward slash with a backslash:
"CN=192.168.0.0\/24,cn=Subnets,CN=Sites,CN=Configuration,DC=mydomain,DC=com"

From: ActiveDir-owner@mail.activedir.org [mailto:ActiveDir-owner@mail.activedir.org] On Behalf Of Joe McNicholas
Sent: Thursday, April 17, 2008 7:35 AM
To: ActiveDir@mail.activedir.org
Subject: [ActiveDir] VBScript + LDAP path + forward slash character = bad


<longshot mode>

Hi all, I'm attempting to write a bit a vbscript to *edit* subnet objects in our AD. I'm struggling to bind to a subnet objectΏ], and cannot find any sample code to do this.

My code is failing because the LDAP path I'm using to bind to the subnet contains a forward slash "/", which is not legal in an LDAP path. Anyone know how to get around this, as its part of the distinguished names of the subnet objects.

Thanks
Joe

Ώ] Example:
CN=192.168.0.0/24,cn=Subnets,CN=Sites,CN=Configuration,DC=mydomain,DC=com


James_DayUser is Offline

Posts:13

04/17/2008 10:24 AM  
Hi All

I cobbled this together (read - I found some code snippets on-line and
merged a bunch of things together) that seems to work. The first column in
the TSV file I use has random tracking value in it that gets put there by
another script I run to pull the same information (because I am inherently
lazy and using the same mechanisms simplify things). If you are using a
header line for your columns, the second column can be labelled "Subnet
Number" and that row will be ignored. Good luck with it. It is possible I
have just violated various copyrights by (A - using this and B - publishing
it here) and if so my sincerest apologies.

wscript.echo "subnet creation begins"
on error resume next
' **************Create error recording file.
Set fso = CreateObject("Scripting.FileSystemObject")
Set fso2 = CreateObject("Scripting.FileSystemObject")
set myfyle = fso.CreateTextFile("modsubneterrors.txt", true)
myfyle.close
set myfyle2 = fso.OpenTextFile("modsubneterrors.txt", 8, true)
' **************Read text file to get the correct info (tab delimited like
so - Unusedcolumnwithanyvalue SubnetNumber Description LocationName
ADSiteName)
set myreadfyle = fso.opentextfile("subnetmods.txt")
While Not myreadfyle.AtEndOfStream
fyleline = myreadfyle.readline
dnarray = split(fyleline,chr(9),-1,1)
if dnarray(1)="Subnet Number" then
' do nothing
elseif dnarray(1) = "" then
' also do nothing
else
dn2array = split(dnarray(4),",",-1,1)
' ************variable Stuff
subnetval= dnarray(1)
siteval = replace(dn2array(0),"CN=","")
desc = dnarray(2)
loca = dnarray(3)

' *************Working stuff
set objRootDSE = GetObject("LDAP://RootDSE")
set objSubnetsCont = GetObject("LDAP://cn=subnets,cn=sites," &
objRootDSE.Get("configurationNamingContext") )
objsubnetscont.filter=array("subnet")
for each objsubnet in objsubnetscont
if objsubnet.get("cn") = subnetval then
objsubnet.put "description",desc
objsubnet.setinfo
if err<>0 then
myfyle2.writeline subnetval & chr(9) & " description update error " &
chr(9) & err
err = 0
end if
objsubnet.put "location", loca
objsubnet.setinfo
if err<>0 then
myfyle2.writeline subnetval & chr(9) & " location update error " &
chr(9) & err
err = 0
end if
end if
next
end if
wend
wscript.echo "DONE"

Regards;

James R. Day
Active Directory Core Team
Office of the Chief Information Officer
National Park Service
202-354-1464
202-230-2983 (CEL)
james_day@contractor.nps.gov



"Joe McNicholas"
<joe@joemcnichola
s.com> To
Sent by: <ActiveDir@mail.activedir.org>
ActiveDir-owner@m cc
ail.activedir.org
Subject
[ActiveDir] VBScript + LDAP path +
04/17/2008 02:35 forward slash character = bad
PM CET


Please respond to
ActiveDir@mail.ac
tivedir.org






<longshot mode>


Hi all, I'm attempting to write a bit a vbscript to *edit* subnet objects
in our AD. I'm struggling to bind to a subnet objectΏ], and cannot find
any sample code to do this.


My code is failing because the LDAP path I'm using to bind to the subnet
contains a forward slash "/", which is not legal in an LDAP path. Anyone
know how to get around this, as its part of the distinguished names of the
subnet objects.


Thanks
Joe


Ώ] Example:
CN=192.168.0.0/24,cn=Subnets,CN=Sites,CN=Configuration,DC=mydomain,DC=com






List info : http://www.activedir.org/List.aspx
List FAQ : http://www.activedir.org/ListFAQ.aspx
List archive: http://www.activedir.org/ma/default.aspx
joe1User is Offline

Posts:5

04/17/2008 10:44 AM  
<slams head on desk>

Thanks guys - works perfectly.

________________________________

From: ActiveDir-owner@mail.activedir.org
[mailto:ActiveDir-owner@mail.activedir.org] On Behalf Of Coleman, Hunter
Sent: 17 April 2008 14:54
To: ActiveDir@mail.activedir.org
Subject: RE: [ActiveDir] VBScript + LDAP path + forward slash character
= bad



Did you try escaping the forward slash with a backslash:

"CN=192.168.0.0\/24,cn=Subnets,CN=Sites,CN=Configuration,DC=mydomain,DC=
com"



From: ActiveDir-owner@mail.activedir.org
[mailto:ActiveDir-owner@mail.activedir.org] On Behalf Of Joe McNicholas
Sent: Thursday, April 17, 2008 7:35 AM
To: ActiveDir@mail.activedir.org
Subject: [ActiveDir] VBScript + LDAP path + forward slash character =
bad



<longshot mode>

Hi all, I'm attempting to write a bit a vbscript to *edit* subnet
objects in our AD. I'm struggling to bind to a subnet objectΏ], and
cannot find any sample code to do this.

My code is failing because the LDAP path I'm using to bind to the subnet
contains a forward slash "/", which is not legal in an LDAP path.
Anyone know how to get around this, as its part of the distinguished
names of the subnet objects.

Thanks
Joe

Ώ] Example:
CN=192.168.0.0/24,cn=Subnets,CN=Sites,CN=Configuration,DC=mydomain,DC=co
m




You are not authorized to post a reply.
Forums >ActiveDir Mail List Archive >List Archives > [ActiveDir] VBScript + LDAP path + forward slash character = bad



ActiveForums 3.7
AdventNet Banner
Friends

Friends

Namescape
Members

Members

MembershipMembership:
Latest New UserLatest:kosciesza69
New TodayNew Today:3
New YesterdayNew Yesterday:1
User CountOverall:4319

People OnlinePeople Online:
VisitorsVisitors:82
MembersMembers:0
TotalTotal:82

Online NowOnline Now:

Ads

Copyright 2008 ActiveDir.org
Terms Of Use