Jump to content
Sign in to follow this  
Seen

Active Directory: SetPassword() Help!

Recommended Posts

Seen

Hey guys. I'm trying to work on a GUI that acts as a user control panel for Active Directory Management.

One of the first things that I'm trying to accomplish is adding a user. Here is my CreateUser() function:

Func CreateUser($userid, $firstname, $lastname)
    $domain = $array_UserControl[1][1]
    $suffix = $array_UserControl[2][1]
    $cn = $array_UserControl[3][1]
    $servername = $array_UserControl[4][1]
    $defaultpassword = "apassword4u"
    $objOU = ObjGet("LDAP://cn=" & $cn & ",dc=" & $domain & ",dc=" & $suffix)
    $objUser = $objOU.Create("User", "cn="& $firstname & " " & $lastname)
    $objUser.Put ("userPrincipalName", "" &  $userid & "@" & $domain & "." & $suffix)
    $objUser.Put ("sAMAccountName", $userid)
    $objUser.Put ("profilePath", "\\" & $servername & "\profiles\" & $userid)
    $objUser.SetPassword ($defaultpassword)
    $objUser.SetInfo()
    $objApp = ObjCreate("Wscript.Shell")
    $objUser.AccountDisabled = 0    
    $objUser.Put ("pwdLastSet", 0)
    $objUser.SetInfo()

EndFunc

However, when I run it, it tells me that when it gets to the SetPassword() part, it fails! No other description aside from that it failed.

What am I doing wrong? Every other source and post that I have checked show that I am using the correct syntax. Please help!

~Seen

Share this post


Link to post
Share on other sites
Monamo

Hey guys. I'm trying to work on a GUI that acts as a user control panel for Active Directory Management.

One of the first things that I'm trying to accomplish is adding a user. Here is my CreateUser() function:

Func CreateUser($userid, $firstname, $lastname)
    $domain = $array_UserControl[1][1]
    $suffix = $array_UserControl[2][1]
    $cn = $array_UserControl[3][1]
    $servername = $array_UserControl[4][1]
    $defaultpassword = "apassword4u"
    $objOU = ObjGet("LDAP://cn=" & $cn & ",dc=" & $domain & ",dc=" & $suffix)
    $objUser = $objOU.Create("User", "cn="& $firstname & " " & $lastname)
    $objUser.Put ("userPrincipalName", "" &  $userid & "@" & $domain & "." & $suffix)
    $objUser.Put ("sAMAccountName", $userid)
    $objUser.Put ("profilePath", "\\" & $servername & "\profiles\" & $userid)
    $objUser.SetPassword ($defaultpassword)
    $objUser.SetInfo()
    $objApp = ObjCreate("Wscript.Shell")
    $objUser.AccountDisabled = 0    
    $objUser.Put ("pwdLastSet", 0)
    $objUser.SetInfo()

EndFunc

However, when I run it, it tells me that when it gets to the SetPassword() part, it fails! No other description aside from that it failed.

What am I doing wrong? Every other source and post that I have checked show that I am using the correct syntax. Please help!

~Seen

My AD scripting is rusty, but if I remember correctly, you need to do a SetInfo before the SetPassword in order to commit the previous changes.

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Share this post


Link to post
Share on other sites
weaponx

In this example (vbscript) they are defining some global constants which might be required: http://techtasks.com/code/viewbookcode/236

EDIT: Also make sure your default password meets the AD complexity requirements.

Edited by weaponx

Share this post


Link to post
Share on other sites
ptrex

Share this post


Link to post
Share on other sites
ptrex

Share this post


Link to post
Share on other sites
Seen

In this example (vbscript) they are defining some global constants which might be required: http://techtasks.com/code/viewbookcode/236

EDIT: Also make sure your default password meets the AD complexity requirements.

I'm 99.9% sure that those constants are not needed for what I am trying to do. I'll try them, however, and I'll let you know how it turns out.

@all

Dim $strPWD, $strLDAP

$strPWD = "x!f98btw"
$strLDAP = "Name,ou=people,dc=cp,dc=com"

$objUser = ObjGet ("LDAP://cn=" & $strLDAP )
$objUser.SetPassword $strPWD

ConsoleWrite ( "Password Changed" )

regards,

ptrex

This is exactly what I am doing.

After moving the SetInfo() before the SetPassword(), All the stuff up until the SetPassword() goes through just fine. This means that:

$objOU = ObjGet("LDAP://cn=" & $ou & ",dc=" & $domain & ",dc=" & $suffix)
    $objUser = $objOU.Create("User", "cn="& $firstname & " " & $lastname)
    $objUser.Put ("userPrincipalName", "" &  $userid & "@" & $domain & "." & $suffix)
    $objUser.Put ("sAMAccountName", $userid)
    $objUser.Put ("profilePath", "\\" & $servername & "\profiles\" & $userid)

goes through just fine.

Even moreso a kicker, when I comment out the SetPassword(), there are 0 problems! I am so confused it hurts!

Nobody else has had this problem? Just for sh!ts and giggles, I'll post the entire script. Maybe there is something else that is wrong...

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=c:\documents and settings\administrator\desktop\form designer\forms\sjtestform.kxf
$Form1_1 = GUICreate("Form1", 381, 295, 313, 210)
$TitleLabel = GUICtrlCreateLabel("SJConsultant User Management Control", 8, 8, 311, 23)
GUICtrlSetFont(-1, 12, 800, 0, "Century Gothic")
$AddLabel = GUICtrlCreateLabel("Add a User: ", 8, 40, 90, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$DeleteButton = GUICtrlCreateButton("Delete User", 288, 224, 83, 25, 0)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$DeleteLabel = GUICtrlCreateLabel("Delete a User:", 8, 168, 104, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$AddInputLast = GUICtrlCreateInput("", 136, 96, 121, 21)
$AddButton = GUICtrlCreateButton("Add User", 288, 128, 83, 25, 0)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$EmailLabel = GUICtrlCreateLabel("Email Enabled?", 280, 72, 91, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$YesEmail = GUICtrlCreateRadio("Yes", 280, 96, 41, 17)
$NoEmail = GUICtrlCreateRadio("No", 320, 96, 49, 17)
$AddInputFirst = GUICtrlCreateInput("", 8, 96, 121, 21)
$FirstLabel1 = GUICtrlCreateLabel("First Name:", 8, 72, 68, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$LastLabel1 = GUICtrlCreateLabel("Last Name:", 136, 72, 68, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$DeleteInputFirst = GUICtrlCreateInput("", 8, 224, 121, 21)
$DeleteInputLast = GUICtrlCreateInput("", 144, 224, 121, 21)
$FirstLabel2 = GUICtrlCreateLabel("First Name: ", 8, 200, 72, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$LastLabel2 = GUICtrlCreateLabel("Last Name:", 144, 200, 68, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$temp=Envget("windir")
$array_UserControl=IniReadSection ( $temp & "\temp\config.ini", "title1")

Func CreateUser($userid, $firstname, $lastname)
    $domain = $array_UserControl[1][1]
    $suffix = $array_UserControl[2][1]
    $ou = $array_UserControl[3][1]
    $servername = $array_UserControl[4][1]
    $defaultpassword = "x!f98btw"
    $objOU = ObjGet("LDAP://cn=" & $ou & ",dc=" & $domain & ",dc=" & $suffix)
    $objUser = $objOU.Create("User", "cn="& $firstname & " " & $lastname)
    $objUser.Put ("userPrincipalName", "" &  $userid & "@" & $domain & "." & $suffix)
    $objUser.Put ("sAMAccountName", $userid)
    $objUser.Put ("profilePath", "\\" & $servername & "\profiles\" & $userid)
    $objUser.SetInfo()
    $objUser.SetPassword $defaultpassword
    $objApp = ObjCreate("Wscript.Shell")
    $objUser.AccountDisabled = 0    
    $objUser.Put ("pwdLastSet", 0)
    $objUser.SetInfo()

EndFunc

    
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $AddButton
            $yesradio=GUICtrlRead($YesEmail)
            $FirstNameAdd=GUICtrlRead($AddInputFirst)
            $noradio=GUICtrlRead($NoEmail)
            $LastNameAdd=GUICtrlRead($AddInputLast)
            $user=StringLeft($FirstNameAdd,1) & $LastNameAdd
            If $yesradio = 1 And Not $FirstNameAdd = "" and Not $LastNameAdd = "" Then
                CreateUser($user, $FirstNameAdd, $LastNameAdd)
                MsgBox(0, "", "User Added with Email access.")
            ElseIf $noradio = 1 And Not $FirstNameAdd = "" and Not $LastNameAdd = "" Then
                MsgBox(0,"","User Added with No Email access.")
            Else
                msgBox(0,"","Please Fill in (and check) all the required fields.")
            EndIf
    EndSwitch
WEnd
Edited by Seen

Share this post


Link to post
Share on other sites
weaponx

I'm 99.9% sure that those constants are not needed for what I am trying to do. I'll try them, however, and I'll let you know how it turns out.

This is exactly what I am doing.

After moving the SetInfo() before the SetPassword(), All the stuff up until the SetPassword() goes through just fine. This means that:

$objOU = ObjGet("LDAP://cn=" & $ou & ",dc=" & $domain & ",dc=" & $suffix)
     $objUser = $objOU.Create("User", "cn="& $firstname & " " & $lastname)
     $objUser.Put ("userPrincipalName", "" &  $userid & "@" & $domain & "." & $suffix)
     $objUser.Put ("sAMAccountName", $userid)
     $objUser.Put ("profilePath", "\\" & $servername & "\profiles\" & $userid)

goes through just fine.

Even moreso a kicker, when I comment out the SetPassword(), there are 0 problems! I am so confused it hurts!

Nobody else has had this problem? Just for sh!ts and giggles, I'll post the entire script. Maybe there is something else that is wrong...

#include <GUIConstants.au3>
 
 #Region ### START Koda GUI section ### Form=c:\documents and settings\administrator\desktop\form designer\forms\sjtestform.kxf
 $Form1_1 = GUICreate("Form1", 381, 295, 313, 210)
 $TitleLabel = GUICtrlCreateLabel("SJConsultant User Management Control", 8, 8, 311, 23)
 GUICtrlSetFont(-1, 12, 800, 0, "Century Gothic")
 $AddLabel = GUICtrlCreateLabel("Add a User: ", 8, 40, 90, 20)
 GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
 $DeleteButton = GUICtrlCreateButton("Delete User", 288, 224, 83, 25, 0)
 GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
 $DeleteLabel = GUICtrlCreateLabel("Delete a User:", 8, 168, 104, 20)
 GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
 $AddInputLast = GUICtrlCreateInput("", 136, 96, 121, 21)
 $AddButton = GUICtrlCreateButton("Add User", 288, 128, 83, 25, 0)
 GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
 $EmailLabel = GUICtrlCreateLabel("Email Enabled?", 280, 72, 91, 17)
 GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
 $YesEmail = GUICtrlCreateRadio("Yes", 280, 96, 41, 17)
 $NoEmail = GUICtrlCreateRadio("No", 320, 96, 49, 17)
 $AddInputFirst = GUICtrlCreateInput("", 8, 96, 121, 21)
 $FirstLabel1 = GUICtrlCreateLabel("First Name:", 8, 72, 68, 17)
 GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
 $LastLabel1 = GUICtrlCreateLabel("Last Name:", 136, 72, 68, 17)
 GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
 $DeleteInputFirst = GUICtrlCreateInput("", 8, 224, 121, 21)
 $DeleteInputLast = GUICtrlCreateInput("", 144, 224, 121, 21)
 $FirstLabel2 = GUICtrlCreateLabel("First Name: ", 8, 200, 72, 17)
 GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
 $LastLabel2 = GUICtrlCreateLabel("Last Name:", 144, 200, 68, 17)
 GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
 GUISetState(@SW_SHOW)
 #EndRegion ### END Koda GUI section ###
 $temp=Envget("windir")
 $array_UserControl=IniReadSection ( $temp & "\temp\config.ini", "title1")
 
 Func CreateUser($userid, $firstname, $lastname)
     $domain = $array_UserControl[1][1]
     $suffix = $array_UserControl[2][1]
     $ou = $array_UserControl[3][1]
     $servername = $array_UserControl[4][1]
     $defaultpassword = "x!f98btw"
     $objOU = ObjGet("LDAP://cn=" & $ou & ",dc=" & $domain & ",dc=" & $suffix)
     $objUser = $objOU.Create("User", "cn="& $firstname & " " & $lastname)
     $objUser.Put ("userPrincipalName", "" &  $userid & "@" & $domain & "." & $suffix)
     $objUser.Put ("sAMAccountName", $userid)
     $objUser.Put ("profilePath", "\\" & $servername & "\profiles\" & $userid)
     $objUser.SetInfo()
     $objUser.SetPassword $defaultpassword
     $objApp = ObjCreate("Wscript.Shell")
     $objUser.AccountDisabled = 0   
     $objUser.Put ("pwdLastSet", 0)
     $objUser.SetInfo()
 
 EndFunc
 
     
 While 1
     $nMsg = GUIGetMsg()
     Switch $nMsg
         Case $GUI_EVENT_CLOSE
             Exit
         Case $AddButton
             $yesradio=GUICtrlRead($YesEmail)
             $FirstNameAdd=GUICtrlRead($AddInputFirst)
             $noradio=GUICtrlRead($NoEmail)
             $LastNameAdd=GUICtrlRead($AddInputLast)
             $user=StringLeft($FirstNameAdd,1) & $LastNameAdd
             If $yesradio = 1 And Not $FirstNameAdd = "" and Not $LastNameAdd = "" Then
                 CreateUser($user, $FirstNameAdd, $LastNameAdd)
                 MsgBox(0, "", "User Added with Email access.")
             ElseIf $noradio = 1 And Not $FirstNameAdd = "" and Not $LastNameAdd = "" Then
                 MsgBox(0,"","User Added with No Email access.")
             Else
                 msgBox(0,"","Please Fill in (and check) all the required fields.")
             EndIf
     EndSwitch
 WEnd
Shouldn't

$objUser.SetPassword $defaultpassword

be

$objUser.SetPassword ($defaultpassword)

???

Share this post


Link to post
Share on other sites
Seen

@all

Dim $strPWD, $strLDAP

$strPWD = "x!f98btw"
$strLDAP = "Name,ou=people,dc=cp,dc=com"

$objUser = ObjGet ("LDAP://cn=" & $strLDAP )
$objUser.SetPassword $strPWD

ConsoleWrite ( "Password Changed" )

regards,

ptrex

Also, I created that exact environment (An OU named people and a user named Name), and copy and pasted that script. Still doesn't work. I tried manually creating that user with that password, and that works just fine.

Is it worth noting that I am doing this all in a VMWare Virtual Server? Would that prevent anything from happening?

Share this post


Link to post
Share on other sites
arcker

can you add objevent comm error

we can't help you more without that

i use setpassword for a while, with win2k and win2k3 and no problem


-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]

Share this post


Link to post
Share on other sites
Seen

can you add objevent comm error

we can't help you more without that

i use setpassword for a while, with win2k and win2k3 and no problem

How do I get the objevent comm error?

Share this post


Link to post
Share on other sites
Seen

*bump*

Still looking for how to generate a Objevent COMM error # .

Share this post


Link to post
Share on other sites
ptrex

@Seen

here you go :

$sFuncName = ObjEvent("AutoIt.Error")
if $sFuncName <> "" then 
    Msgbox (0,"Test","User has installed Error Handler function: " & $sFuncName)
EndIf

; Initialize error handler 
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

; Your code here

;------------------------------ This is a COM Error handler --------------------------------
Func MyErrFunc()
  $HexNumber=hex($oMyError.number,8)
  Msgbox(0,"COM Error Test","We intercepted a COM Error !"       & @CRLF  & @CRLF & _
             "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
             "err.windescription:"     & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "         & @TAB & $HexNumber              & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "     & @TAB & $oMyError.scriptline     & @CRLF & _
             "err.source is: "         & @TAB & $oMyError.source         & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile       & @CRLF & _
             "err.helpcontext is: "    & @TAB & $oMyError.helpcontext _
            )
  SetError(1)  ; to check for after this function returns
Endfunc

regards

ptrex

Share this post


Link to post
Share on other sites
Seen

Ok, I get:

COMM Error

# 8002000E

Description: Invalid number of parameters.

Line 58.

Full Code:

$sFuncName = ObjEvent("AutoIt.Error")
if $sFuncName <> "" then 
    Msgbox (0,"Test","User has installed Error Handler function: " & $sFuncName)
EndIf

; Initialize error handler 

#include <GUIConstants.au3>
#include<adfunctions.au3>

#Region ### START Koda GUI section ### Form=c:\documents and settings\administrator\desktop\form designer\forms\sjtestform.kxf
$Form1_1 = GUICreate("Form1", 381, 295, 313, 210)
$TitleLabel = GUICtrlCreateLabel("SJConsultant User Management Control", 8, 8, 311, 23)
GUICtrlSetFont(-1, 12, 800, 0, "Century Gothic")
$AddLabel = GUICtrlCreateLabel("Add a User: ", 8, 40, 90, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$DeleteButton = GUICtrlCreateButton("Delete User", 288, 224, 83, 25, 0)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$DeleteLabel = GUICtrlCreateLabel("Delete a User:", 8, 168, 104, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$AddInputLast = GUICtrlCreateInput("", 136, 96, 121, 21)
$AddButton = GUICtrlCreateButton("Add User", 288, 128, 83, 25, 0)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$EmailLabel = GUICtrlCreateLabel("Email Enabled?", 280, 72, 91, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$YesEmail = GUICtrlCreateRadio("Yes", 280, 96, 41, 17)
$NoEmail = GUICtrlCreateRadio("No", 320, 96, 49, 17)
$AddInputFirst = GUICtrlCreateInput("", 8, 96, 121, 21)
$FirstLabel1 = GUICtrlCreateLabel("First Name:", 8, 72, 68, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$LastLabel1 = GUICtrlCreateLabel("Last Name:", 136, 72, 68, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$DeleteInputFirst = GUICtrlCreateInput("", 8, 224, 121, 21)
$DeleteInputLast = GUICtrlCreateInput("", 144, 224, 121, 21)
$FirstLabel2 = GUICtrlCreateLabel("First Name: ", 8, 200, 72, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$LastLabel2 = GUICtrlCreateLabel("Last Name:", 144, 200, 68, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$temp=Envget("windir")
$array_UserControl=IniReadSection ( $temp & "\temp\config.ini", "title1")

Func CreateUser($userid, $firstname, $lastname)
    $domain = $array_UserControl[1][1]
    $suffix = $array_UserControl[2][1]
    $ou = $array_UserControl[3][1]
    $servername = $array_UserControl[4][1]
    $defaultpassword = "PassWord10!"
    $objOU = ObjGet("LDAP://cn=" & $ou & ",dc=" & $domain & ",dc=" & $suffix)
;~  $objOU = ObjGet("LDAP://cn=Users,dc=vmtest,dc=local")
    $objUser = $objOU.Create("User", "cn="& $firstname & " " & $lastname)
    $objUser.Put ("userPrincipalName", "" &  $userid & "@" & $domain & "." & $suffix)
    $objUser.Put ("sAMAccountName", $userid)
    $objUser.Put ("profilePath", "\\" & $servername & "\profiles\" & $userid)
    $objUser.SetInfo()
    $objUser.GetInfo()
    $objUser.SetPassword $defaultpassword
    $objApp = ObjCreate("Wscript.Shell")
    $objUser.AccountDisabled = 0    
    $objUser.Put ("pwdLastSet", 0)
    $objUser.SetInfo()


EndFunc

    
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $AddButton
            $yesradio=GUICtrlRead($YesEmail)
            $FirstNameAdd=GUICtrlRead($AddInputFirst)
            $noradio=GUICtrlRead($NoEmail)
            $LastNameAdd=GUICtrlRead($AddInputLast)
            $user=StringLeft($FirstNameAdd,1) & $LastNameAdd
            $userexist = _ADObjectExists($user)
            If $yesradio = 1 And Not $FirstNameAdd = "" and Not $LastNameAdd = "" Then
                If $userexist = 1 Then 
                    msgbox(0,"",$FirstNameAdd & " " & $LastNameAdd & " is alerady in the system.")
                Else
                    CreateUser($user, $FirstNameAdd, $LastNameAdd)
                    MsgBox(0, "", "User Added with Email access.")
                EndIf
                
            ElseIf $noradio = 1 And Not $FirstNameAdd = "" and Not $LastNameAdd = "" Then
                If $userexist = 1 Then 
                    msgbox(0,"",$FirstNameAdd & " " & $LastNameAdd & " is alerady in the system.")
                Else
                    CreateUser($user, $FirstNameAdd, $LastNameAdd)
                    MsgBox(0,"","User Added with No Email access.")
                EndIf
            Else
                msgBox(0,"","Please Fill in (and check) all the required fields.")
            EndIf
        Case $DeleteButton
            $FirstNameDelete=GuiCtrlRead($DeleteInputFirst)
            $LastNameDelete=GuiCtrlRead($DeleteInputLast)
            $user=StringLeft($FirstNameDelete,1) & $LastNameDelete
            $userexist = _ADObjectExists($user)
            $var="tester"
            If $userexist = 1 Then 
                $ou=_ADSamAccountNameToFQDN("Users")
                $type="user"
;~              $userid=_ADSamAccountNameToFQDN($user)
                _ADDeleteObject($ou, $user, $type)
                MsgBox(0, "", "Bahleeted.")
            Else
                msgbox(0,"",$FirstNameAdd & " " & $LastNameAdd & " doesn't exist.")
            EndIf
            
    EndSwitch
WEnd


;------------------------------ This is a COM Error handler --------------------------------
Func MyErrFunc()
  $HexNumber=hex($oMyError.number,8)
  Msgbox(0,"COM Error Test","We intercepted a COM Error !"     & @CRLF  & @CRLF & _
             "err.description is: " & @TAB & $oMyError.description  & @CRLF & _
             "err.windescription:"   & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "       & @TAB & $HexNumber              & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "   & @TAB & $oMyError.scriptline   & @CRLF & _
             "err.source is: "       & @TAB & $oMyError.source       & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile     & @CRLF & _
             "err.helpcontext is: " & @TAB & $oMyError.helpcontext _
            )
  SetError(1) ; to check for after this function returns
Endfunc

Hope this helps debug it. Thanks a lot for the error handling code, ptrex.

Edited by Seen

Share this post


Link to post
Share on other sites
Seen

0_o. Weird.

So I did some forum searching on that error, and it said it was a syntax error. It said to try using Brackets

So I did SetPassword ($defaultpassword)

And it worked. I could have sworn I did this before, but I guess not.

Sorry to bug everyone.

Thanks again to ptrex for giving me the error handling script! Your awesome!

~Seen

Share this post


Link to post
Share on other sites
ptrex
weaponx

0_o. Weird.

So I did some forum searching on that error, and it said it was a syntax error. It said to try using Brackets

So I did SetPassword ($defaultpassword)

And it worked. I could have sworn I did this before, but I guess not.

Sorry to bug everyone.

Thanks again to ptrex for giving me the error handling script! Your awesome!

~Seen

Reminds me of a reply I once posted. As a matter of fact it was in this same topic! Weird!

#405241

Share this post


Link to post
Share on other sites
Seen

Like I said before, I coulda SWORE I did that.

But, apparently not. Looks like I'm Human :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×