Jump to content

Recommended Posts

Posted

As the Active Directory UDF - Help & Support thread has grown too big, I start a new one.

The original thread can be found

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

Going back to the other thread questions, the UDF is UDF Version 1.3.0.0. Remeber that I had an issue with the IE error handler because I need to have both in my program. So you told me to add a couple lines. Would that be why the line count number is off?

When I used the old version of the UDF, it works fine (0.41)

Posted

Can you please post the line where you call _AD_ObjectDelete including the content of all parameters you pass?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

I just have it like this. I set the $TheUser field with the username of the person I am trying to delete.

$iValue = _AD_DeleteObject($TheUser, "user")

Posted

You have to set $TheUser to the SamAccountName (that's the ID you use for logon) or the FQDN like CN=UserId,OU=..DC=..,DC=..

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

Can you please post the result of

ConsoleWrite(_AD_SamAccountNameToFQDN($TheUser))

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

Looks like the escape character ("") causes the problem.

Will have to create a test script to further track this down.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

Can you please run this modified version to delete the user so we get some additzional debugging info?

Func _AD_DeleteObjectEX($sAD_Object, $sAD_Class)

    If Not _AD_ObjectExists($sAD_Object) Then Return SetError(1, 0, 0)
    Local $sAD_CN
    If StringMid($sAD_Object, 3, 1) <> "=" Then $sAD_Object = _AD_SamAccountNameToFQDN($sAD_Object) ; sAMAccountName provided
ConsoleWrite("$sAD_Object: " & @error & "-" & $sAD_Object & @LF)
    Local $oAD_Object = __AD_ObjGet("LDAP://" & $sAD_HostServer & "/" & $sAD_Object)
ConsoleWrite("__AD_ObjGet $sAD_Object: " & @error & "-" & IsObj($oAD_Object) & @LF)
    Local $oAD_OU = __AD_ObjGet($oAD_Object.Parent) ; Get the object of the OU/CN where the object resides
ConsoleWrite("__AD_ObjGet $oAD_OU: " & @error & "-" & IsObj($oAD_OU) & @LF)
    If $sAD_Class = "organizationalUnit" Then
        $sAD_CN = "OU=" & _AD_GetObjectAttribute($sAD_Object, "ou")
    Else
        $sAD_CN = "CN=" & _AD_GetObjectAttribute($sAD_Object, "cn")
    EndIf
ConsoleWrite("_AD_GetObjectAttribute: " & @error & "-" & $sAD_CN & @LF)
    $oAD_OU.Delete($sAD_Class, $sAD_CN)
    If @error <> 0 Then Return SetError(@error, 0, 0)
    Return 1

EndFunc

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

Good day.

did you read my last post about diagnostic results?

If the results show nothing could you help me with getting content of created object please?

I'm sure the origins of this error will be understood under results comparing.

Posted

Hi tarankov,

Yes, I've read your last post. Unfortunately I'm quite busy at the moment and haven't yet found the time to dive into the subject.

I have no experience with AD permissions. Function _AD_CreateComputer is a complete copy of the original function written by Jonathan Clelland taken from his adfunctions UDF.

The original script was taken from here.

I'm not sure the whole permission thing is needed at all. Maybe if no permissions are set everyone can join the computer to the domain. So this should work too:

Func _AD_CreateComputer($sAD_OU, $sAD_Computer, $sAD_User)

    If Not _AD_ObjectExists($sAD_OU) Then Return SetError(1, 0, 0)
    If _AD_ObjectExists("CN=" & $sAD_Computer & "," & $sAD_OU) Then Return SetError(2, 0, 0)
    If Not _AD_ObjectExists($sAD_User) Then Return SetError(3, 0, 0)
    If StringMid($sAD_OU, 3, 1) <> "=" Then $sAD_OU = _AD_SamAccountNameToFQDN($sAD_OU) ; sAMACccountName provided
    If StringMid($sAD_User, 3, 1) = "=" Then $sAD_User = _AD_FQDNToSamAccountName($sAD_User) ; FQDN provided
    Local $oAD_Container = __AD_ObjGet("LDAP://" & $sAD_HostServer & "/" & $sAD_OU)
    Local $oAD_Computer = $oAD_Container.Create("Computer", "cn=" & $sAD_Computer)
    $oAD_Computer.Put("sAMAccountName", $sAD_Computer & "$")
    $oAD_Computer.Put("userAccountControl", BitOR($ADS_UF_PASSWD_NOTREQD, $ADS_UF_WORKSTATION_TRUST_ACCOUNT))
    $oAD_Computer.SetInfo
    If @error <> 0 Then Return SetError(@error, 0, 0)
    Return 1

EndFunc   ;==>_AD_CreateComputer

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted (edited)

Can you please run this modified version to delete the user so we get some additzional debugging info?

Func _AD_DeleteObjectEX($sAD_Object, $sAD_Class)

If Not _AD_ObjectExists($sAD_Object) Then Return SetError(1, 0, 0)
Local $sAD_CN
If StringMid($sAD_Object, 3, 1) <> "=" Then $sAD_Object = _AD_SamAccountNameToFQDN($sAD_Object) ; sAMAccountName provided
ConsoleWrite("$sAD_Object: " & @error & "-" & $sAD_Object & @LF)
Local $oAD_Object = __AD_ObjGet("LDAP://" & $sAD_HostServer & "/" & $sAD_Object)
ConsoleWrite("__AD_ObjGet $sAD_Object: " & @error & "-" & IsObj($oAD_Object) & @LF)
Local $oAD_OU = __AD_ObjGet($oAD_Object.Parent) ; Get the object of the OU/CN where the object resides
ConsoleWrite("__AD_ObjGet $oAD_OU: " & @error & "-" & IsObj($oAD_OU) & @LF)
If $sAD_Class = "organizationalUnit" Then
$sAD_CN = "OU=" & _AD_GetObjectAttribute($sAD_Object, "ou")
Else
$sAD_CN = "CN=" & _AD_GetObjectAttribute($sAD_Object, "cn")
EndIf
ConsoleWrite("_AD_GetObjectAttribute: " & @error & "-" & $sAD_CN & @LF)
$oAD_OU.Delete($sAD_Class, $sAD_CN)
If @error <> 0 Then Return SetError(@error, 0, 0)
Return 1

EndFunc

Here are the results of that

$sAD_Object: 0-CN=LNAME, FNAME,OU=Users,OU=Supervisors,OU=OPERATIONS,OU=Location - HO,DC=Domain,DC=com

__AD_ObjGet $sAD_Object: 0-1

__AD_ObjGet $oAD_OU: 0-1

_AD_GetObjectAttribute: 0-CN=LNAME, FNAME

--> COM Error Encountered in Suite_tray.au3

----> $IEComErrorScriptline = 30353

----> $IEComErrorNumberHex = 80020009

----> $IEComErrorNumber = -2147352567

----> $IEComErrorWinDescription = An invalid dn syntax has been specified.

----> $IEComErrorDescription =

----> $IEComErrorSource =

----> $IEComErrorHelpFile =

----> $IEComErrorHelpContext = 0

----> $IEComErrorLastDllError = 0

-2147352567-0

Edited by bartekd
Posted

That looks much better now. Can you please give this function a try:

Func _AD_DeleteObjectEX($sAD_Object, $sAD_Class)

    If Not _AD_ObjectExists($sAD_Object) Then Return SetError(1, 0, 0)
    Local $sAD_CN
    If StringMid($sAD_Object, 3, 1) <> "=" Then $sAD_Object = _AD_SamAccountNameToFQDN($sAD_Object) ; sAMAccountName provided
ConsoleWrite("$sAD_Object: " & @error & "-" & $sAD_Object & @LF)
    Local $oAD_Object = __AD_ObjGet("LDAP://" & $sAD_HostServer & "/" & $sAD_Object)
ConsoleWrite("__AD_ObjGet $sAD_Object: " & @error & "-" & IsObj($oAD_Object) & @LF)
    Local $oAD_OU = __AD_ObjGet($oAD_Object.Parent) ; Get the object of the OU/CN where the object resides
ConsoleWrite("__AD_ObjGet $oAD_OU: " & @error & "-" & IsObj($oAD_OU) & @LF)
    If $sAD_Class = "organizationalUnit" Then
        $sAD_CN = "OU=" & _AD_FixSpecialChars(_AD_GetObjectAttribute($sAD_Object, "ou"))
    Else
        $sAD_CN = "CN=" & _AD_FixSpecialChars(_AD_GetObjectAttribute($sAD_Object, "cn"))
    EndIf
ConsoleWrite("_AD_GetObjectAttribute: " & @error & "-" & $sAD_CN & @LF)
    $oAD_OU.Delete($sAD_Class, $sAD_CN)
    If @error <> 0 Then Return SetError(@error, 0, 0)
    Return 1

EndFunc

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

That looks much better now. Can you please give this function a try:

Func _AD_DeleteObjectEX($sAD_Object, $sAD_Class)

If Not _AD_ObjectExists($sAD_Object) Then Return SetError(1, 0, 0)
Local $sAD_CN
If StringMid($sAD_Object, 3, 1) <> "=" Then $sAD_Object = _AD_SamAccountNameToFQDN($sAD_Object) ; sAMAccountName provided
ConsoleWrite("$sAD_Object: " & @error & "-" & $sAD_Object & @LF)
Local $oAD_Object = __AD_ObjGet("LDAP://" & $sAD_HostServer & "/" & $sAD_Object)
ConsoleWrite("__AD_ObjGet $sAD_Object: " & @error & "-" & IsObj($oAD_Object) & @LF)
Local $oAD_OU = __AD_ObjGet($oAD_Object.Parent) ; Get the object of the OU/CN where the object resides
ConsoleWrite("__AD_ObjGet $oAD_OU: " & @error & "-" & IsObj($oAD_OU) & @LF)
If $sAD_Class = "organizationalUnit" Then
$sAD_CN = "OU=" & _AD_FixSpecialChars(_AD_GetObjectAttribute($sAD_Object, "ou"))
Else
$sAD_CN = "CN=" & _AD_FixSpecialChars(_AD_GetObjectAttribute($sAD_Object, "cn"))
EndIf
ConsoleWrite("_AD_GetObjectAttribute: " & @error & "-" & $sAD_CN & @LF)
$oAD_OU.Delete($sAD_Class, $sAD_CN)
If @error <> 0 Then Return SetError(@error, 0, 0)
Return 1

EndFunc

$sAD_Object: 0-CN=LNAME, FNAME,OU=Users,OU=Supervisors,OU=OPERATIONS,OU=Location - HO,DC=Domain,DC=com

__AD_ObjGet $sAD_Object: 0-1

__AD_ObjGet $oAD_OU: 0-1

_AD_GetObjectAttribute: 0-CN=LName, FNAME

0-0

That worked like a charm. thanks. :) If you update your UDF, can you include that and also the other change you asked me to make regarding the error handler a couple pages back?

Posted

If you update your UDF, can you include that and also the other change you asked me to make regarding the error handler a couple pages back?

Sure. I've already changed the source of the UDF and added to bug reports to page 1 of the download thread.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

Thanks for helping me to pin down this bug :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

This is a continuation of my issue here

I tried it with a pc that I joined to the domain and received the same error message.

also to note I figured I would just try and join a pc to the domain to a computer object I created manually using the AD management tools from MS.

When I did this using my same AD_Open statement I got extended error 2202, which according to MS website is bad username. I tried to add my user directly to the joindomain command and then I get error 2 instead. If I run getallous it works fine so I know my userid is correct and it is a domain admin so has rights.

Posted

I tried to add my user directly to the joindomain command and then I get error 2 instead

Error 2 as returned by _AD_JoinDomain means: $sAD_UserParam does not exist in the domain.

How did you specify the username?

According to the help file:

NetBIOSName (domainuser) or user principal name (user@domain)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...