+ Post New Thread
Results 1 to 13 of 13
Scripts Thread, Problems with a simple password reset program in VB6 in Coding and Web Development; Hi All, First let me tell you my scenario. I am a technician at a secondary school. We have a ...
  1. #1
    TriggerHappyUK's Avatar
    Join Date
    Oct 2007
    Location
    Dorset
    Posts
    71
    Thank Post
    61
    Thanked 5 Times in 4 Posts
    Rep Power
    14

    Problems with a simple password reset program in VB6

    Hi All,

    First let me tell you my scenario. I am a technician at a secondary school. We have a medium sized network with AD, running server 2003 and XP clients.

    I am trying to create a very simple VB6 executable that will reset a students password and force a password change at next logon. I'm no expert at VB but I can work my way around a program.

    I have designed the very simple form: see attached

    Here is the code:

    Code:
    Private Sub cmdExit_Click()
        End
    End Sub
    
    Private Sub cmdSubmit_Click()
    
        Dim objOU As Object, objUser As Object, objRootDSE As Object
        Dim strContainer As String, strDNSDomain As String, strPassword As String
        Dim intPwdValue As Integer
        
        'Bind to Active Directory Domain
        Set objRootDSE = GetObject("LDAP://RootDSE")
        strDNSDomain = objRootDSE.get("DefaultNamingContext")
    
        strContainer = "OU=Domain Users, "
        strPassword = "P@ssw0rd"
        strContainer = strContainer & strDNSDomain
    
        'Here we force a change of password at next logon
        intPwdValue = 0
    
        Set objOU = GetObject("LDAP://cn=" & txtStuNum.Text & ", " & strContainer)
        objUser.SetPassword strPassword
        objUser.Put "PwdLastSet", intPwdValue
        objUser.SetInfo
    
       
    End Sub
    When I run it, I enter the student's number in the text box and click submit, then and error is thrown at me.

    "Run-time error '2147016656 (80072030)': There is no such object on the server"

    When I debug, the "Set objOU = GetObject("LDAP://cn=" & txtStuNum.Text & ", " & strContainer)" line is highlighted in yellow.

    Any help to get this working would be greatly appreciated.

    Cheers for looking,

    Chris.
    Attached Images Attached Images

  2. #2

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    13,272
    Thank Post
    613
    Thanked 1,567 Times in 1,407 Posts
    Rep Power
    412
    Something doesn't look quite right with this bit " & txtStuNum.Text & ", " & strContainer)" the things enclosed in quotes would be passed as literal text and not the values which they are set to wouldn't they?

    Ben

  3. #3

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,859
    Thank Post
    412
    Thanked 777 Times in 650 Posts
    Rep Power
    182
    No, look at the actual code, which is correct. You're quoting a quote, the whole of which is wrapped in quote marks - you know, like English should be.

    @TriggerHappyUK: build your distinguished name string in a variable first and dump it out just before the call to GetObject, so you can see exactly what it says.

  4. #4

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    13,272
    Thank Post
    613
    Thanked 1,567 Times in 1,407 Posts
    Rep Power
    412
    Hmm yes ok I see now that it does appear to be correct.

    2 ways to check do as has been suggested and dump out what the string builds to or hardcode a value to be correct and run it like that and then see what it does.

    Ben

  5. #5

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,859
    Thank Post
    412
    Thanked 777 Times in 650 Posts
    Rep Power
    182
    Quote Originally Posted by plexer View Post
    or hardcode a value to be correct and run it like that and then see what it does.
    If a hard value succeeds, it still doesn't help you to pin down the error... you need to know what the string looks like after you've concatenated the parts, not whether your library calls can be trusted (which you have to assume is the case, otherwise libraries would be useless).

  6. #6
    TriggerHappyUK's Avatar
    Join Date
    Oct 2007
    Location
    Dorset
    Posts
    71
    Thank Post
    61
    Thanked 5 Times in 4 Posts
    Rep Power
    14
    Quote Originally Posted by powdarrmonkey View Post
    @TriggerHappyUK: build your distinguished name string in a variable first and dump it out just before the call to GetObject, so you can see exactly what it says.
    Thanks for the comments... Could you be a bit clearer please. It's been a while since I have done any programming.

    Chris.

  7. #7

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,859
    Thank Post
    412
    Thanked 777 Times in 650 Posts
    Rep Power
    182
    Quote Originally Posted by TriggerHappyUK View Post
    Thanks for the comments... Could you be a bit clearer please. It's been a while since I have done any programming.
    Something like:

    Code:
    Dim strDN As String
    strDN = ""LDAP://cn=" & txtStuNum.Text & ", " & strContainer
    Debug.Print strDN
    Set objOU = GetObject(strDN)

  8. #8
    TriggerHappyUK's Avatar
    Join Date
    Oct 2007
    Location
    Dorset
    Posts
    71
    Thank Post
    61
    Thanked 5 Times in 4 Posts
    Rep Power
    14
    Here is where I am now:

    Code:
    Private Sub cmdExit_Click()
        End
    End Sub
    
    Private Sub cmdSubmit_Click()
    
        Dim objOU As Object, objUser As Object, objRootDSE As Object
        Dim strContainer As String, strDNSDomain As String, strPassword As String
        Dim strDN As String
        Dim intPwdValue As Integer
        
        'Bind to Active Directory Domain
        Set objRootDSE = GetObject("LDAP://RootDSE")
        strDNSDomain = objRootDSE.get("DefaultNamingContext")
    
        strContainer = "OU=Domain Users,"
        strPassword = "P@ssw0rd"
        strContainer = strContainer & strDNSDomain
    
        'Here we force a change of password at next logon
        intPwdValue = 0
    
    
        strDN = ("LDAP://cn=" & txtStuNum.Text & "," & strContainer)
        Debug.Print strDN
        Set objOU = GetObject(strDN)
     
        'Set objOU = GetObject("LDAP://cn=" & txtStuNum.Text & "," & strContainer)
        objUser.SetPassword strPassword
        objUser.Put "PwdLastSet", intPwdValue
        objUser.SetInfo
    
    End Sub
    When I run it, I get the same error:

    "Run-time error '2147016656 (80072030)': There is no such object on the server"

    When I debug, the "Set objOU = GetObject(strDN)" line is highlighted in yellow.

    This may help, the value of strDN is:

    LDAP://cn=0007,OU=Domain Users,DC=arnewood,DC=net

    But the value of objOU has a value of:

    Nothing

  9. #9
    TriggerHappyUK's Avatar
    Join Date
    Oct 2007
    Location
    Dorset
    Posts
    71
    Thank Post
    61
    Thanked 5 Times in 4 Posts
    Rep Power
    14
    Just added a message box to test the value of strDN inplace of the debug.print. It outputted the same value as above before crashing with the same error.

  10. #10

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,432
    Thank Post
    1,432
    Thanked 1,160 Times in 794 Posts
    Rep Power
    705
    Quote Originally Posted by TriggerHappyUK View Post
    Just added a message box to test the value of strDN inplace of the debug.print. It outputted the same value as above before crashing with the same error.
    Those two will return the same as they're both just displaying the value of strDN.

    Might be a daft question, but you are sure that there is a student 0007 on the domain?

  11. #11
    TriggerHappyUK's Avatar
    Join Date
    Oct 2007
    Location
    Dorset
    Posts
    71
    Thank Post
    61
    Thanked 5 Times in 4 Posts
    Rep Power
    14
    Quote Originally Posted by LosOjos View Post
    Those two will return the same as they're both just displaying the value of strDN.

    Might be a daft question, but you are sure that there is a student 0007 on the domain?
    Yeah, that's out test student account.

  12. #12
    TriggerHappyUK's Avatar
    Join Date
    Oct 2007
    Location
    Dorset
    Posts
    71
    Thank Post
    61
    Thanked 5 Times in 4 Posts
    Rep Power
    14
    This little .exe(Password Reset tool for staff) works a treat and is so nearly what I am hoping to achieve. It changes the password fine but I would like to force a password change at next logon.

  13. #13
    Chad's Avatar
    Join Date
    May 2007
    Location
    Elgin
    Posts
    74
    Thank Post
    5
    Thanked 20 Times in 19 Posts
    Rep Power
    18
    Shouldn't:
    Code:
    Set objOU = GetObject("LDAP://cn=" & txtStuNum.Text & "," & strContainer)

    be

    Code:
    Set objUser = GetObject("LDAP://cn=" & txtStuNum.Text & "," & strContainer)

    as you don't seem to be assigning a value to objUser before attempting to change the password?

    If you still get a "no such object on server" error, I'd suggest grabbing an LDAP browser and checking the path to your test object.

    Chad
    Last edited by Chad; 9th July 2010 at 04:31 PM.

SHARE:
+ Post New Thread

Similar Threads

  1. Self Service Password Reset
    By plexer in forum EduGeek Self Service Password Reset
    Replies: 273
    Last Post: 5th November 2013, 06:51 PM
  2. bulk password reset
    By Jonny_sims in forum Windows
    Replies: 10
    Last Post: 26th September 2011, 10:12 PM
  3. Simple Texteaselike program
    By TechSupp in forum Educational Software
    Replies: 0
    Last Post: 26th February 2010, 09:58 AM
  4. [Fog] Reset Fog Password
    By matte53 in forum O/S Deployment
    Replies: 3
    Last Post: 13th October 2009, 09:27 PM
  5. reset admin password
    By fafster in forum Windows
    Replies: 11
    Last Post: 27th February 2008, 10: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
  •