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))

    # 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()

    # 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 (215k points)
selected by
Best answer


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 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)
0 votes
0 answers

Hi Just starting to trial Adaxes and so far so good. Haven't quite grasped the PowerShell v ADSI features and was hoping someone could assist with my PS script. Basically I ... long, just wondering if I can somehow use the Adaxes ADSI to make it better. Thanks

asked Aug 22, 2016 by jask747 (20 points)
0 votes
1 answer

Hello, I am looking for a way with a custom command or script to change ExtensionAttribute4 for all users in a specific OU(and Sub-OU's). Currently all of the ... change them to firstname.lastname@yyy.com just changing the field after the @ symbol. Thank You

asked Mar 19, 2016 by Infounlim (470 points)
2,779 questions
2,512 answers
25,896 users