Jump to content

Recommended Posts

Posted

Hi

 

I am having a little trouble with this script i have put together, I get a type mismatch on Line21 Char 1.

 

Line reads

 

set Domain = GetObject("LDAP://"& "ou=" & recordSet & ",OU=Wisemore Campus,OU=Student Computers Vista,DC=walcat,DC=ac,DC=uk")

 

Any idea's?

Thanks

 

Mike

 

 

Full script follows

 

'Script to create Active Directory OU Groups based on a list of names in a CSV file.

Option Explicit

dim connection, recordSet, orgUnit, inputFile, Domain, inputFileLocation, newOU

inputFileLocation = "c:\"	'Location\Target Path of CSV file
inputFile = "c:\ounames.csv"	'File Name

set connection = createobject("adodb.connection")
set recordSet = createobject("adodb.recordset")

connection.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " & inputFileLocation & ";Extended Properties=""text;HDR=YES;FMT=Delimited"""
recordSet.open "SELECT * FROM " & inputFile, connection, 3, 3, &H0001

'on error resume next

do until recordset.EOF 'Continue until end of file (EOF)
orgUnit=recordSet(0)

set Domain = GetObject("LDAP://"& "ou=" & recordSet & ",OU=Wisemore Campus,OU=Student Computers Vista,DC=walcat,DC=ac,DC=uk")
set newOU = Domain.Create("organizationalUnit", "ou=Computers")
newOU.SetInfo
set newOU = Nothing

recordSet.movenext
loop

msgbox "Finished Creating OU's"

Posted

Not an expect with VB script and LDAP, but I have had issues in the past when OU's have spaces in them when using login scripts that read the OU information. It might be an idea to try renaming your OUs so they don't have any spaces and alter the script accordingly just as one possible thing to try.

 

Mike.

Posted

what is recordset

 

set Domain = GetObject("LDAP://"& "ou=" & recordSet & ",OU=Wisemore Campus,OU=Student Computers Vista,DC=walcat,DC=ac,DC=uk")

 

You have all the above but I do not see anything being assigned to that variable ?

 

Also if you just do a simple script with the relevant coding and make a msgbox output the full ou does it output correctly ?

 

I'm not that familiar with LDAP in vbscripting but if you go to the server and go to the properties of the OU I think it shows you there the full correct OU etc so maybe try that ?

Posted

recordset contains the list of OUs read from the CSV file.

 

I think the error line should read:

set Domain = GetObject("LDAP://"& "ou=" & orgUnit & ",OU=Wisemore Campus,OU=Student Computers Vista,DC=walcat,DC=ac,DC=uk")

I suspect the code was originally going to be:

set Domain = GetObject("LDAP://"& "ou=" & recordset(0) & ",OU=Wisemore Campus,OU=Student Computers Vista,DC=walcat,DC=ac,DC=uk")

 

but I can't quickly check this because I've got 64 bit Vista and 64 bit Windows 7 on my desk and neither works with ADO!!

Posted

Mike

 

TRY

set Domain = GetObject("LDAP://"& "ou=" & orgUnit & ",OU=Wisemore Campus,OU=Student

 

rather than

set Domain = GetObject("LDAP://"& "ou=" & recordSet & ",OU=Wisemore Campus,OU=Student

 

 

recordSet is a row from your csv file

 

orgUnit=recordSet(0) - ???? Is this index correct - this should assign the OU from the row to the variable orgUnit

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...