Hi,
Another option can be that one. First, the code below will search for a user across all configured ADs. Just provide a `userName` value. The object will be returned only if there is an exact match.
var users = [];
users = ActiveDirectory.searchExactMatch('User', userName);
if (users.length === 0) return
for each (user in users) {
// do you logic and return an array of AD:User objects
}
PS. You can try to use `ActiveDirectory.search('User', userName)` and see if that gives you a better result for your needs.
Now, when you have an array of `AD:Users` you want to delete, just call this function:
function deleteUsers(adUsersObjectToDelete) {
for each (user in adUsersObjectToDelete) {
user.destroy();
}
}