How can we check email format for multiple users in AD

Anusha 1 Reputation point
2022-08-16T07:33:50.273+00:00

Hello,

   How can we check the email format of multiple users in Active directory at a time? is that possible using python.  

Thanks,

Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
5,799 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Gary Reynolds 9,391 Reputation points
    2022-08-18T00:08:35.657+00:00

    Hi @Anusha

    I haven't done much with Python and AD but I did help on another question which includes some details on using Python using a couple of different libraries.

    https://learn.microsoft.com/en-us/answers/questions/948475/python-set-attributes-ldap.html

    Here on the other hand here is a Powershell script which can be used to valid the mail address for users active users. You just need to change the domain name.

    get-aduser -filter 'enabled -eq $true' -properties givenname,sn,mail,samaccountname |   
        foreach-object{   
            [PSCustomObject]@{   
                Name = $_.SamAccountName;  
                Mail = $_.Mail  
                Valid = "$($_.givenname).$($_.sn)@yourmaildomain.com" -eq $_.mail;  
             }  
         } | Export-Csv c:\temp\mail-Report.csv -notypeinformation  
    

    Gary.