0 votes

We will be adding email aliases to the proxyaddresses attribute in order to track our Google Apps mailbox aliases (no Exchange here). I currently have a script that Support helped us with and it is checking the mail attribute for change and verifying that the address doesn't exist before creating or modifying the user object. I have even added the proxyaddresses attribute into the LDAP filter in the script and it does work to make sure that an address placed into the mail attribute doesn't already exist as an alias. I now need to also check when an alias is placed into the proxyaddresses attribute to make sure it is not already in use. Proxyaddresses is a multi-value attribute, so I did not know if I could just copy this script and change it to where is pulls the new address from proxyaddresses instead of mail or if it would even work. We may add one or many aliases at one time and will need to insure that the addresses are not in use.

Help with this would be greatly appreciated.

if ($Context.IsPropertyModified("mail"))
{
    # Get Email address
    $mail = $Context.GetModifiedPropertyValue("mail");

    # Check whether the email address is empty
    if ([System.String]::IsNullOrEmpty($mail))
    {
        return
    }

    # Search all users 
    $searcher = New-Object "Softerra.Adaxes.Adsi.Search.DirectorySearcher" $NULL, $False
    $searcher.SearchParameters.PageSize = 500
    $searcher.SearchParameters.SearchScope = "ADS_SCOPE_SUBTREE"
    $searcher.SearchParameters.Filter = "(&(objectCategory=user)(|(mail=$mail)(proxyaddresses=$mail)))"
    $searcher.VirtualRoot = $True

    $result = $searcher.ExecuteSearch()
    $users = $result.FetchAll()
    $result.Dispose()

    # Check if the Email address is unique
    if($users.Count -ne 0)
    {
        $Context.Cancel("Email address is already in use. Please verify that account is not being duplicated");
    }
}
by (1.2k points)

1 Answer

0 votes
by (216k points)
selected by
Best answer

Hello,

Have a look at this forum posting: Google Apps Email Aliases?.

Related questions

0 votes
1 answer

Hello, I have another issue, with SMS verification code. My SMS gateway provides me soap interface to send text messages, and also email to SMS. And now my two ... : plain / quotedprintable / base64, at least in the subject line? Best Regards Michael

asked Aug 13, 2012 by MichalMMM (60 points)
0 votes
1 answer

Hello Support Team We are looking to change our email address format to first.last@company.com. We have some newer users using the new format but we never backfilled the ... (NOT set to primary) to each account and deal with the possibility of duplicates?

asked Jun 5, 2018 by willy-wally (3.2k points)
0 votes
1 answer

Hi, we just recently installed Adaxes and would like to implement a PowerShell script that I have previously written which cleans up user objects if they have been manually ... to perform the operation Stack trace: at <ScriptBlock>, <No file>".

asked Oct 2, 2023 by Mark.Monaco (20 points)
0 votes
1 answer

This will run in a business rule "after creating a user" The email should be set to %firstname:lower%%lastname:lower%@mydomain. If the email isn't unique then it ... failure. This should update the emailaddress attribute in AD(not updating anything in Azure).

asked Feb 2, 2023 by mightycabal (1.0k points)
0 votes
1 answer

Hi smart people! I'm using this script: http://www.adaxes.com/script-repository ... t-s423.htm Which works great for sending an email to someone, listing their direct ... body of the email at once would be greatly appreciated! Thanks for any and all replies!

asked Mar 24, 2017 by 3Jake (150 points)
3,346 questions
3,047 answers
7,782 comments
544,982 users