Jump to content

Active Directory UDF


water
 Share

Recommended Posts

supersonic,

This will be "fixed" with the next AutoIt version. Because the new version no longer relies on a COM error handler.

water

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

 

Link to comment
Share on other sites

I will test a soon as I'm in my office again.

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

 

Link to comment
Share on other sites

I use 3.3.8.1 as well and just ran the _AD_ObjectExists.au3 example script and didn't have a problem.

If you run your own script, can you please post the code?

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

 

Link to comment
Share on other sites

Is it possible to create a small (max. 10 lines) reproducer script?

There are too many includes I need to download and some errors I get.

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

 

Link to comment
Share on other sites

I'm trying to add an email field in the general tab of a user but _AD_ModifyAttribute does not work. It works for the First name: , Last name: , Display name: , Description: , Office: but not for E-mail; _AD_AddEmailAddress does not do it either. Any suggestion?

Link to comment
Share on other sites

The email field can't be set by _AD_ModifyAttribute or any other function of the AD UDF. It's set by Exchange as soon as you create a mailbox.

The _AD_AddEmailAddress function "appends an SMTP email address to the 'Email Addresses' tab of an Exchange-enabled AD account."

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

 

Link to comment
Share on other sites

At the moment there is no _AD_CreateContact function. But shouldn't be too hard to create one.

Do you have a test environment where you could play with such a function? I only have read access here.

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

 

Link to comment
Share on other sites

Should be something like this (untested):

Func _AD_CreateContact($sAD_OU, $sAD_Contact)

If _AD_ObjectExists($sAD_Contact) Then Return SetError(1, 0, 0)
If Not _AD_ObjectExists($sAD_OU, "distinguishedName") Then Return SetError(2, 0, 0)
Local $sAD_CN = "CN=" & _AD_FixSpecialChars($sAD_Contact)
Local $oAD_OU = __AD_ObjGet("LDAP://" & $sAD_HostServer & "/" & $sAD_OU)
Local $oAD_Contact = $oAD_OU.Create("Contact", $sAD_CN)
#cs
Local $sAD_SamAccountName = StringReplace($sAD_Contact, ",", "")
$sAD_SamAccountName = StringReplace($sAD_SamAccountName, "#", "")
$sAD_SamAccountName = StringReplace($sAD_SamAccountName, "/", "")
$oAD_Contact.sAMAccountName = $sAD_SamAccountName
$oAD_Contact.SetInfo
If @error <> 0 Then Return SetError(@error, 0, 0)
#ce
Return 1

EndFunc ;==>_AD_CreateContact
I'm not sure the part between #cs and #ce is needed.

If the function works can you check that the field "samaccountname" has a value?

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

 

Link to comment
Share on other sites

The email field can't be set by _AD_ModifyAttribute or any other function of the AD UDF. It's set by Exchange as soon as you create a mailbox.

The _AD_AddEmailAddress function "appends an SMTP email address to the 'Email Addresses' tab of an Exchange-enabled AD account."

My AD is 2008R2 and my exchange is 2007 with multiple domains. IE: purple.com, orange.com, green.com.

Typically when I create a user in the AD, I specify the E-mail field to abc_user@orange.com. Then in Exchange 2007 when I create a mailbox for abc_user, the email address abc_user@orange.com is automatically created. Is there another way around this?

Link to comment
Share on other sites

Should be something like this (untested):

Func _AD_CreateContact($sAD_OU, $sAD_Contact)

If _AD_ObjectExists($sAD_Contact) Then Return SetError(1, 0, 0)
If Not _AD_ObjectExists($sAD_OU, "distinguishedName") Then Return SetError(2, 0, 0)
Local $sAD_CN = "CN=" & _AD_FixSpecialChars($sAD_Contact)
Local $oAD_OU = __AD_ObjGet("LDAP://" & $sAD_HostServer & "/" & $sAD_OU)
Local $oAD_Contact = $oAD_OU.Create("Contact", $sAD_CN)
#cs
Local $sAD_SamAccountName = StringReplace($sAD_Contact, ",", "")
$sAD_SamAccountName = StringReplace($sAD_SamAccountName, "#", "")
$sAD_SamAccountName = StringReplace($sAD_SamAccountName, "/", "")
$oAD_Contact.sAMAccountName = $sAD_SamAccountName
$oAD_Contact.SetInfo
If @error <> 0 Then Return SetError(@error, 0, 0)
#ce
Return 1

EndFunc ;==>_AD_CreateContact
I'm not sure the part between #cs and #ce is needed.

If the function works can you check that the field "samaccountname" has a value?

Tried it both ways, doesn't work.
Link to comment
Share on other sites

We use a PowerShell script to create the Exchange mailbox (I have posted it somewhre on the forum). All AD settings are then being done automatically. IIRC our Exchange admin has set up some rules on the Exchange server how the mail address has to be created in AD.

As I'm not the AD nor the Exchange admin I don't know for sure what goes on behind the scenes.

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

 

Link to comment
Share on other sites

You pass the OU where the contact needs to be created as parameter 1 and the RDN (relative distinguished name) - without the leading "CN=" - as parameter 2?

Edited by water

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

 

Link to comment
Share on other sites

We use a PowerShell script to create the Exchange mailbox (I have posted it somewhre on the forum). All AD settings are then being done automatically. IIRC our Exchange admin has set up some rules on the Exchange server how the mail address has to be created in AD.

As I'm not the AD nor the Exchange admin I don't know for sure what goes on behind the scenes.

The AD environment I work in is complicated due to the multiple domain. I can also create a user in Exchange without Powershell, but then the user is created somewhere in the AD OU, which I would have to search and move them to the proper OU. When I add users to the AD, typically I would need to create 4-5 users per location. Some users have mailboxes, some don't. This is why I need to come up with a script to do everything in one shot.

Edited by l4tran
Link to comment
Share on other sites

The script we run here does everything in one shot. It creates the user in AD using the functions of the AD UDF. To create the mailbox a PowerShell script is called.

When the script ends the user has all he needs: An AD account assigned to some basic groups, all necessary directories (home, mail archive ...) with correctly set permissions, Exchange mailbox etc.

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

 

Link to comment
Share on other sites

If you run the current version of the AD UDF (1.3.0.0) could you please add "_AD_ErrorNotify(2)" at the top of your script and post the returned COM error message?

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

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...