While enumerating Sharepoint user profiles like this
foreach (Microsoft.Office.Server.UserProfiles.UserProfile userProfile in profileManager)
if the user don’t have administrator privileges, then the following exception will occur.
“System.UnAuthorizedException : Access Denied – Only Administrator may enumerate through all user profiles”.
To resolve this, proceed with the following steps..
1. Go to SSP – > Personalization services permissions
2. Modify Permissions for NT AUTHORITY\Authenticated Users
3. Select the option “User Profile Manager” and Save.
Now you are ready to enumerate the Sharepoint User Profiles…