I used the GPGME function gpgme_op_assuan_transact_ext with an query string like this:
ad_query --subst --attr=dn,userAccountControl (&(objectcategory=person)(objectclass=user) (|(userPrincipalName={{email}}) (mail={{email}})))
Of course {{email}} must be replaced with the mail address queried, this might probably also be the login name.