I do the same as is described above, but all the same leaves:
Result: Leave empty to use the Administrator in LDAP Settings
calling ldap_connect with: "*******" and port "389"
setting LDAP_OPT_PROTOCOL_VERSION to 3 and LDAP_OPT_REFERRALS to 0
binding to ldap with "*******" and his password
using the filter: "(&(sAMAccountName=pvv))"
calling ldap_search with the domain: "DC=***,DC=local", the Filter: "(&(sAMAccountName=pvv))" and the Attributes: "array("givenname")"
LDAP returned field data: "Владимир"
Debug of function ldapGetEmail():
getting the email of user: "pvv"
binding to ldap with "*****" and his password
calling ldap_search with the domain: "DC=*****,DC=local", the Filter: "(&(sAMAccountName=pvv))" and the Attributes: "array("mail")"
LDAP returned field data: "*******"
Debug of function ldapGetUsernameFromEmail():
getting the user of email: "*****"
binding to ldap with "*****" and his password
calling ldap_search with the domain: "DC=****,DC=local", the Filter: "(&(mail=*****))" and the Attributes: "array("samaccountname")"
LDAP returned field data: "pvv"