I’ve encountered a situation where I need to be able to lookup a user by their active directory name. I’ve tried looking for the user in the SPSite.Users, SPSite.AllUsers and SPSite.SiteUsers properties, but the user isn’t guaranteed to be in any of those lists. For users who gain permission to the site via an active directory group that has been granted permission to the site, there is no listing for the user in the various user lists, only a record for the active directory group. Is there a way to find a user programmatically in SharePoint without directly having to query active directory via LDAP?
I would ideally like to find a mechanism that works for both forms based authentication and AD authentication, but I need to find a mechanism that works with AD authentication.