Hi - I'm trying to validate that the email address entered is distinct. The logic below is not working.
When we had Exchange, this was automatic. We no longer have Exchange, so email is just the "mail" attribute in Active Directory. I simply want to prevent a user from entering an already present address.
Similar logic to this works just fine with other attributes (employeeid for example).
Import-Module Adaxes
if ($Context.IsPropertyModified("mail"))
{
# Get the value specified by the user
$value = $Context.GetModifiedPropertyValue("mail");
# Validate mail
# Ensure that the mail is unique
if ((Get-AdmUser -Filter 'mail -eq $value') -ne $NULL)
{
$Context.Cancel("A user with the specified mail address already exists!");
return $false;
}
}