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

I need to change the following script to evaluate if the timestamp in a custom atribute is older than 1 year than the current date. # The condition is met ... .DayOfYear)) { $Context.ConditionIsMet = $True } else { $Context.ConditionIsMet = $False }

asked Dec 13, 2024 by msheppard (720 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

We are using the below snippet to grab the email of a single custom attribute object. Can I get guidance on the best way to modify this to get all the emails of each ... "The user specified in parameter 'MyParameter' has no email address. ", "Information") }

asked Dec 23, 2024 by msheppard (720 points)
3,614 questions
3,301 answers
8,366 comments
548,574 users