Jump to content
noobieautolearn

Active Directory UDF Email issue

Recommended Posts

noobieautolearn

I was working with ADU and I was trying to get the email address function to work but when I try I end up with the error message as seen in the attachment. I did some searching and found out that this means "unknown error". Water said that that means I might not have write access to AD but I can assure you that I am running the script with a domain admin account and the other strange thing is, if I run this test script on another account that existed before it does work.  Has any run into issues with not being able to set the email address of an account that they created with ADU?

Active Directory UDF.png

Edited by noobieautolearn

Share this post


Link to post
Share on other sites
water

It would help if you could post your script.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
noobieautolearn
20 hours ago, water said:

It would help if you could post your script.

I'm just using the sample script to add an email address that came in the zip file.

 

_AD_AddEmailAddress.au3

Does the command check any attributes and if it isn't set it won't add the email address?

 

Edited by noobieautolearn

Share this post


Link to post
Share on other sites
water

A COM error handler returns better results. Please add the following line at the top of your script:

_AD_ErrorNotify(2)

This will write detailed error information to a MsgBox.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
noobieautolearn
11 hours ago, water said:

A COM error handler returns better results. Please add the following line at the top of your script:

_AD_ErrorNotify(2)

This will write detailed error information to a MsgBox.

Ok, I ran it and I attached the error I got below. Also note that I have used this same sample script successfully on other AD accounts but so far the one I created with ADU has not worked and I have tried this on some other accounts that currently don't have email addresses attached and they haven't worked either.

What I'm going to do is set the email, emailnick, proxy and target and try the same account to see if I get errors.

 

So I have sort of figured out what is going on, if I go into the account and add a mail attribute and a proxy address attribute the script works.  So then that brings up the question I have is, if I want to use your suite (thank you for creating it) to create a brand new user and I want to of course have all the attributes filled in during the creation process including mail, mailnick, proxyaddress and target address what would I need to do?  Or should that Add email address example script work even if none of those attributes are filled out?

 

 

AD error2.png

Edited by noobieautolearn

Share this post


Link to post
Share on other sites
water

That's exactly what happens. You can add an "SMTP email address to the 'Email Addresses' tab of an Exchange-enabled AD account."
Means: You first have to create th mailbox, then you can add further addresses.
In my company we use a PowerShell script to create the mailbox. If needed I can share this script.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
rudi

Hi @water

Could you pls share the PS code you've mentioned?

 

thx, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites
water

Snippet of my script to create new users for Exchange 2016:

Global $hFile = FileOpen(@ScriptDir & "\NewEmployee.ps1", $FO_OVERWRITE)
    FileWrite($hFile, _
            "$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://YourExchangeServerNameGoesHere.CompanyName.com/PowerShell/ -Authentication Kerberos" & @CRLF & _
            "Import-PSSession $Session" & @CRLF & _
            "Enable-Mailbox -Identity " & $sUserID & " -Alias " & $sUserID & @CRLF & _
            "Remove-PSSession $Session" & @CRLF)
    FileClose($hFile)
    $sCMD = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -file " & @ScriptDir & "\NewEmployee.ps1"
    $pid = Run($sCMD, @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD + $STDERR_CHILD)
    StdinWrite($pid, @CRLF)
    StdinWrite($pid)
    ; Process STDOUT
    $sSTDOUT = ""
    While 1
        $sOutput = StdoutRead($pid)
        If @error Then ExitLoop
        If $sOutput <> "" Then $sSTDOUT = $sSTDOUT & @CRLF & $sOutput
    WEnd
    ; Process STDERR
    $sSTDERR = ""
    While 1
        $sOutput = StderrRead($pid)
        If @error Then ExitLoop
        If $sOutput <> "" Then $sSTDERR = $sSTDERR & @CRLF & $sOutput
    WEnd
    If StringStripWS($sSTDERR, 3) = "" Then
        _FileWriteLog($sLogFile, "I (" & @AutoItPID & ") " & $sUserID & ": Mailbox successfully created.")
    Else
        Exit _Error("Error creating Exchange mailbox!" & @CRLF & $sSTDERR)
    EndIf

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
noobieautolearn
6 hours ago, water said:

Snippet of my script to create new users for Exchange 2016:

Global $hFile = FileOpen(@ScriptDir & "\NewEmployee.ps1", $FO_OVERWRITE)
    FileWrite($hFile, _
            "$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://YourExchangeServerNameGoesHere.CompanyName.com/PowerShell/ -Authentication Kerberos" & @CRLF & _
            "Import-PSSession $Session" & @CRLF & _
            "Enable-Mailbox -Identity " & $sUserID & " -Alias " & $sUserID & @CRLF & _
            "Remove-PSSession $Session" & @CRLF)
    FileClose($hFile)
    $sCMD = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -file " & @ScriptDir & "\NewEmployee.ps1"
    $pid = Run($sCMD, @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD + $STDERR_CHILD)
    StdinWrite($pid, @CRLF)
    StdinWrite($pid)
    ; Process STDOUT
    $sSTDOUT = ""
    While 1
        $sOutput = StdoutRead($pid)
        If @error Then ExitLoop
        If $sOutput <> "" Then $sSTDOUT = $sSTDOUT & @CRLF & $sOutput
    WEnd
    ; Process STDERR
    $sSTDERR = ""
    While 1
        $sOutput = StderrRead($pid)
        If @error Then ExitLoop
        If $sOutput <> "" Then $sSTDERR = $sSTDERR & @CRLF & $sOutput
    WEnd
    If StringStripWS($sSTDERR, 3) = "" Then
        _FileWriteLog($sLogFile, "I (" & @AutoItPID & ") " & $sUserID & ": Mailbox successfully created.")
    Else
        Exit _Error("Error creating Exchange mailbox!" & @CRLF & $sSTDERR)
    EndIf

 

We have office 365 and don't use on prem exchange.  What we need to do is create an account with mail, mailnick, proxyaddresses and target and it gets imported to our O365 portal where it gets licensed.

Share this post


Link to post
Share on other sites
water

Then maybe function _AD_ModifyAttribute is the way to add those properties to a user?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.