Results 1 to 6 of 6

Thread: Help! (Long Post, but I'm desperate)

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2007
    Posts
    5

    Help! (Long Post, but I'm desperate)

    Hello everyone, first time poster and a first time "VB" user. I guess you could call me that. Let me preface my problem with a few things:

    - I'm an IT worker, but by no means a programmer
    - I've taken precisely one class in programming, and it was Java (last year)
    - I'm using Notepad to create VBScripts to help our summer at a K-12 School district easier by making a self-service password reset script.

    So here I go... I've been working all week on a Password Reset script, and I can't do it anymore. I've googled the world over, and I've managed to throw together a script that will almost do the trick.

    However, this script is just part of my main script that will reset the passwords. This segment--I segmented my script into parts, to ensure each part was working properly (and this is the part that doesn't work) is supposed to retrieve a name,via InputBox, and match/resolve it with the user name in the active directory via LDAP, and then continue with the rest of the script (not pictured) to reset the password. I don't know what else to explain, so I'm just throwing the script there, and praying that a kind soul can correct my error(s). I always assume any error I make is a small oversight.

    A few more notes about our network...
    - We have a domain called STUDENT, where our student accounts are stored. STUDENT is a part of our domain, BRIDGECITYISD.com.
    - Hanz Magoo (username scheme: hanz.magoo) is a theoretical user, and more or less an inside joke with my co-workers. He is the account in question that we would like to reset.
    - I've had so many errors, but I've changed so much that previous errors don't show up, but the error that occurs with this exact version is on Line 33, "An Operations Error Occurred." Code: 80072020.

    So without further ado, here she is:

    call_ldap_name.vbs
    -------------------------
    vb Code:
    1. Option Explicit
    2. Dim objOU, objUser, objUserName, objRootDSE
    3. Dim strContainer, strDNSDomain, strPassword, strLastName, strFirstName, strMyName, strLDAPName
    4. Dim intCounter, intAccValue, intPwdValue, intpwdLastSet, intAnswer
    5.    
    6. strContainer = "OU=High School,DC=Student,DC=bridgecityisd,DC=com"
    7. strPassword = "l33tsauce@"
    8. intAccValue = 544
    9. intPwdValue = 0
    10. strLastName = ""
    11. strFirstName = ""
    12. strLDAPName = ""
    13.    
    14. strFirstName = InputBox ("Enter your First Name:")
    15. strLastName = InputBox ("Enter your Last Name:")
    16. strMyName = strFirstName & "." & strLastName
    17. WScript.echo "UserName is: " & strMyName
    18.    
    19. WScript.echo "Script Will Now Attempt to Resolve Name to LDAP"             
    20. WScript.sleep 1500
    21.    
    22. Set objRootDSE = GetObject("LDAP://RootDSE")
    23. strDNSDomain = objRootDSE.Get("DefaultNamingContext")
    24. strContainer = strContainer & strDNSDomain
    25. set objOU = GetObject("LDAP://ou=High School,dc=student,dc=bridgecityisd,dc=com")
    26. 'Wscript.echo "objOU is: " & objOU
    27.    
    28. strLDAPName = strLDAPName & strLastName &", "& strFirstName
    29.    
    30. Wscript.echo "Unresolved LDAP Name is: " & strLDAPName
    31.    
    32. Set objUser = GetObject("LDAP://cn=strLDAPName,ou=strContainer")
    33. WScript.echo "Resolved LDAP UserName is: " & objUser.CN
    34. WScript.quit
    ------------------
    Last edited by Hack; Jun 2nd, 2007 at 04:48 AM. Reason: Added VB Highlight Tags

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: Help! (Long Post, but I'm desperate)

    Starting with Option Explicit as line 1, line 33 is WScript.echo "Resolved LDAP UserName is: " & objUser.CN. Evidently the line above it isn't setting it to anything usable.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2007
    Posts
    5

    Re: Help! (Long Post, but I'm desperate)

    That's one thing I was wondering about, can I call other objects in getObject?

  4. #4

    Thread Starter
    New Member
    Join Date
    Jun 2007
    Posts
    5

    Re: Help! (Long Post, but I'm desperate)

    Quote Originally Posted by Al42
    Starting with Option Explicit as line 1, line 33 is WScript.echo "Resolved LDAP UserName is: " & objUser.CN. Evidently the line above it isn't setting it to anything usable.
    *bumping* I appreciate the insight on where to locate the cause of the problem in my script, but I've tinkered with it and I'm unable to find anything to fix it. Any suggestions?

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Help! (Long Post, but I'm desperate)

    Quote Originally Posted by star_topology
    *bumping* I appreciate the insight on where to locate the cause of the problem in my script, but I've tinkered with it and I'm unable to find anything to fix it. Any suggestions?
    What "tinkering" have you done?

  6. #6

    Thread Starter
    New Member
    Join Date
    Jun 2007
    Posts
    5

    Re: Help! (Long Post, but I'm desperate)

    Well, now I can get the script to run, but I'm getting a different error; the "no object found on the server" on line 34. As you can see, I added another string, DContainer.

    vb Code:
    1. Option Explicit
    2. Dim objOU, objUser, objUserName, objRootDSE
    3. Dim strContainer, strDNSDomain, strPassword, strLastName, strFirstName, strMyName, strLDAPName, strDContainer
    4. Dim intCounter, intAccValue, intPwdValue, intpwdLastSet, intAnswer
    5.     '5
    6. strContainer = "OU=High School,"
    7. strDContainer = ", dc=student, dc=bridgecityisd, dc=com"
    8. strPassword = "l33tsauce@"
    9. intAccValue = 544
    10. intPwdValue = 0
    11. strLastName = ""
    12. strFirstName = ""
    13. strLDAPName = ""
    14.     '14
    15. strFirstName = InputBox ("Enter your First Name:")
    16. strLastName = InputBox ("Enter your Last Name:")
    17. strMyName = strFirstName & "." & strLastName
    18. WScript.echo "UserName is: " & strMyName
    19.     '19
    20. WScript.echo "Script Will Now Attempt to Resolve Name to LDAP"             
    21.     '21
    22. WScript.sleep 1500
    23.     '23
    24. Set objRootDSE = GetObject("LDAP://RootDSE")
    25. strDNSDomain = objRootDSE.Get("DefaultNamingContext")
    26. strContainer = strContainer & strDNSDomain
    27. set objOU = GetObject("LDAP://"&strContainer)
    28. 'Wscript.echo "objOU is: " & objOU
    29.     '29
    30. strLDAPName = strLDAPName & strLastName &", "& strFirstName
    31.     '31
    32. Wscript.echo "Unresolved LDAP Name is: " & strLDAPName
    33.     '33
    34. Set objUser = GetObject("LDAP://cn="& strLDAPName & strContainer & strDContainer)
    35.     '35
    36. If objUser.cn = strLDAPName then
    37. WScript.echo "Resolved LDAP UserName is: " & objUser.cn
    38. End if
    39. WScript.quit

Posting Permissions

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



Click Here to Expand Forum to Full Width