Add e-mail, username, and search root improvements for ActiveDirectory.
This change makes our ActiveDirectory support more flexible in that we
now use the "mail" field when available for e-mail addresses and we no
longer break when "givenName" or "sn" is not available. This also
introduces a "Custom search root" field in settings for users who need
to fully override the search root.
This change is based on a patch by Ted Dunning, but has been modified to
include siteconfig settings and to break less with mail.
This also fixes the givenName/sn issue on LDAP.
I don't have an ActiveDirectory setup to test. This seems pretty safe, though, and shouldn't cause regressions.