Find accounts where UPN does not Match Email

There is probably an easy way to accomplish this but I'm having some difficulties.

Need a way in a workflow search to find any AD account where UPN does not match email address.   Can't seem to find a way to accomplish this using a filter in my Search activity...

Parents
  • Thank you for the response but I cannot seem to get this to work.  I have a first search that pulls all accounts with mailboxes, no issues there it successfully pulls all accounts with email.  Then another search right beneath that, that pulls all accounts from the first search where upn does not match email of Found Object (First search).   The second search though does not find the accounts where UPN does not match email.   Not sure where I am going wrong here, seems this should work.  Any screenshots you can provide?  I must be missing something here.   Much appreciated.

Reply
  • Thank you for the response but I cannot seem to get this to work.  I have a first search that pulls all accounts with mailboxes, no issues there it successfully pulls all accounts with email.  Then another search right beneath that, that pulls all accounts from the first search where upn does not match email of Found Object (First search).   The second search though does not find the accounts where UPN does not match email.   Not sure where I am going wrong here, seems this should work.  Any screenshots you can provide?  I must be missing something here.   Much appreciated.

Children
  • Workflow overview

    First-level Search

    Second-level Search, nested within first-level Search

    Report section, nested within second-level Search

    Sample results of running the workflow

    Looking at properties of user John Smith, the Email indeed does not match the UPN.

  • very frustrating as I have the same exact set up but its not yielding any results, I'm searching a specific OU with two accounts in it that have non matching UPNs/Emails yet it doesnt return results.

    Would it be possible to expand out your nested search activity and show me the regex filter being used?  This is what I am showing:

    Executing the 'Search for nonmatching upn' activity

    8/30/2022 7:39:01 PM (UTC)
    • Activity started a search.
       Details <<<
      Search base: Test User (domain.com/Accounts/Users/ARTEST)
      Search scope: One level
      Filter: (&(&(!(userPrincipalName=testuser@domain.com)))(&(objectCategory=person)(objectSid=*)(!(sAMAccountType:1.2.840.113556.1.4.804:=3))(!(userAccountControl:1.2.840.113556.1.4.804:=2048))))
  • Executing the 'Search for nonmatching upn' activity

    8/30/2022 7:09:26 PM (UTC)

    •Activity started a search. Details <<<
    Search base: John Smith (dev.ops/Enterprise)
    Search scope: Subtree
    Filter: (&(&(!(userPrincipalName=jsmith@company.com)))(&(objectCategory=person)(objectSid=*)(!(sAMAccountType:1.2.840.113556.1.4.804:=3))(!(userAccountControl:1.2.840.113556.1.4.804:=2048))))

  • Fixed!   In the nested search, I changed the option to "Retrieve any objects held in the OU or container"  and then it started giving me the correct results...  I noticed in your last screen shot, it said "Search scope: subtree" whereas mine said "Search scope: One level".

    Thanks so much for all your help.  I cant thank you enough!