"attrSearchCountAccounts" not checking mail addresses in all OU's

Hi Folks,

I am using below query to search for any existing mail or proxy address attributes during user creation. If its “0” then it will take the default mail else it will increment with 1 to create unique mail attributes.

But, if any user matches mail exist in different OU, then it is not searching for that attribute.

Example: User ‘Test’ exist in OU “ORG1” with mail ‘[email protected]’. Now during new user creation, below query is searching mail in AD with ‘[email protected]’ in AD, but if user exist in different OU other then user’s actual OU to be created, say “ORG2”, then it is taking the same mail "‘[email protected]’, instead of incrementing it.

-------------------- Code------------
do {
String newEmail = namePrefix + (suffixCounter == 0 ? “” : String.valueOf(suffixCounter)) + emailSuffix;
List emailCandidate = new ArrayList(Arrays.asList(new String {
“smtp:” + newEmail, “SMTP:” + newEmail,newEmail
}));

if(idn.attrSearchCountAccounts(sourceId, SEARCH_ATTR_NAME, SEARCH_EQUALS_OP, emailCandidate) == 0 && idn.attrSearchCountAccounts(sourceId, SEARCH_MAILATTR_NAME2, SEARCH_EQUALS_OP, emailCandidate) == 0)

Please suggest if we can add search OU filter around this to work. So it will check all AD’s OU for any value.

Thanks