Discussion in 'Scripting' started by newbie, Aug 12, 2003.

  1. newbie

    newbie Guest

    i'm having a little trouble with my script, hoped someone
    could help me out. it's a casting error i believe. it
    says it needs an object, not a string, and i can't quite
    seem to get it to work.

    Set ObjOU= GetObject

    Const ForReading = 1
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objTextFile = objFSO.OpenTextFile _
    ("c:\users.txt", ForReading)
    Do Until objTextFile.AtEndOfStream
    strNextLine = objTextFile.Readline
    arrServiceList = Split(strNextLine , "&")
    Set ObjUser= arrServiceList(0)
    For i = 1 to Ubound(arrServiceList)
    objUser.SetPassword arrServiceList(i)
    set Objuser= CreateObject(arrServiceList(i + 1))
    newbie, Aug 12, 2003
    1. Advertisements

  2. newbie

    Yoann Roman Guest

    i'm having a little trouble with my script, hoped someone
    See below:
    This is your problem; use the string to get the User object, not as the user
    Yoann Roman, Aug 12, 2003
    1. Advertisements

  3. newbie

    Yoann Roman Guest

    wait, what? i don't quite understand what you mean

    The first part of your script, as I read it, is reading usernames from a
    file. Apparently, you are then parsing each line based on the & symbol (it's
    hard to know why without seeing the format). Now, you use a Set command to
    set objUser to a string parsed out of that line. First of, the "Set" command
    is reserved for objects; a string in VBScript is not an object.

    For example, you're doing this:
    Set objUser = "test"

    This makes no sense for strings; it makes no sense to use
    objUser.SetPassword afterwards either. I see you later use a CreateObject
    method based on what you parsed out of the file. Perhaps you have something
    reversed... without seing the text file, it's hard to troubleshoot. What
    exactly are you trying to accomplish here?
    Yoann Roman, Aug 12, 2003
  4. newbie

    Yoann Roman Guest

    wait, what? i don't quite understand what you mean
    Well, I've not done any LDAP queries, but here is my guess on how to get a
    user from an OU. You probably want some error handling in here in case a
    user no longer exists.

    ' Constants
    Const ForReading = 1

    ' Open the user/password file
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set ts = objFSO.OpenTextFile("c:\users.txt", ForReading)

    ' Change all users listed in the file
    Do Until ts.AtEndOfStream
    strNextLine = ts.Readline
    If Len(strNextLine) > 0 Then
    arUser = Split(strNextLine , "&")
    Set objUser= GetObject("LDAP://CN=" & _
    arUser(0) & ",OU=someplace,DC=" & _
    objUser.SetPassword arUser(1)
    Set objUser = Nothing
    End If

    ' Close the file and clean up
    Set ts = Nothing
    Set objFSO = Nothing
    Yoann Roman, Aug 14, 2003
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.