+ Post New Thread
Results 1 to 5 of 5
Coding Thread, VBS Create OU and containers in Coding and Web Development; Hi I am having a little trouble with this script i have put together, I get a type mismatch on ...
  1. #1

    Join Date
    Jul 2009
    Location
    Staffs
    Posts
    76
    Thank Post
    10
    Thanked 9 Times in 7 Posts
    Rep Power
    12

    VBS Create OU and containers

    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

    Code:
    '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"

  2. #2

    maniac's Avatar
    Join Date
    Feb 2007
    Location
    Kent
    Posts
    3,037
    Thank Post
    209
    Thanked 425 Times in 306 Posts
    Rep Power
    144
    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.

  3. #3

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,710
    Thank Post
    3,246
    Thanked 1,048 Times in 970 Posts
    Rep Power
    364
    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 ?

  4. #4

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,154
    Thank Post
    114
    Thanked 527 Times in 450 Posts
    Blog Entries
    2
    Rep Power
    123
    recordset contains the list of OUs read from the CSV file.

    I think the error line should read:
    Code:
    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:
    Code:
    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!!

  5. #5

    Join Date
    Feb 2009
    Posts
    45
    Thank Post
    1
    Thanked 5 Times in 5 Posts
    Rep Power
    12
    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

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 6
    Last Post: 21st May 2009, 10:16 PM
  2. Solaris Containers How-To Guide
    By matt40k in forum *nix
    Replies: 0
    Last Post: 6th May 2009, 04:08 PM
  3. VBS Scribt
    By RobPrince in forum Scripts
    Replies: 1
    Last Post: 6th April 2009, 01:14 PM
  4. A little .vbs help please
    By ozzy in forum Scripts
    Replies: 9
    Last Post: 27th February 2009, 08:07 AM
  5. VBS Tutorial
    By Nij.UK in forum Coding
    Replies: 15
    Last Post: 25th November 2006, 12:01 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •