I'm developing an asp.net intranet website with a ActiveDirectoryMembershipProvider and a SqlProfileProvider.
One of the requirements of my website is to have a "Birthdays" page, which would require me to list all profiles and retrieving the birthday information from it.
I approached the problem as follows:
- Invoke the Membership.GetAllUsers() static method;
- Iterate through the list of users and retrieve the profile from the member's user name
This approach, however, failed for the following reasons:
- The webapp is impersonating the current logged user to retrieve its AD details (identity impersonate="true" in the web.config), so I get an exception "access is denied" when trying to invoke the GetAllUsers
- If I do try to make the webapp impersonate a super user account then AD returns the user names as username@domain-name format, but in my profile provider they were initially stored as domain-name\username format.
So, how would you go around this problem to retrieve the whole list of profiles for any member of the organization?