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 have designed the very simple form: see attached
Here is the code:

Private Sub cmdExit_Click()
End Sub

Private Sub cmdSubmit_Click()

    Dim objOU, objUser, objRootDSE
    Dim strContainer, strDNSDomain, strPassword
    Dim intPwdValue

    '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

    'objUser = (txtStuNum.Text)
    Set objOU = GetObject("LDAP://" & strContainer)
    objUser = (txtStuNum.Text)
    objUser.SetPassword strPassword
    objUser.Put "PwdLastSet", intPwdValue

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 '424': Object required"

When I debug, the "objUser.SetPassword strPassword" line is highlighted in yellow.

Any help to get this working would be greatly appreciated.

Cheers for looking,


Attachments Form.JPG 14.95 KB
8 Years
Discussion Span
Last Post by vb5prgrmr

What you are trying to do via VB can be done by the net admin with a few mouse clicks... Then there is the potential that this could be so misused...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.