You should 'refresh' the data in A/D into SPS using
the SPS Profile Database (Site Settings, Manager
profile database). You can also set it to automatic
refresh once in a while.
Then you can use the following code to approach the
UserProfiles (eg to retrieve for the current user) in
your webpart:
// extract the uri from the current site
SPWeb spc = SPControl.GetContextWeb(Context);
Uri uri1 = new Uri(spc.Site.RootWeb.Url);
// initializing GlobalAdmin
SPGlobalAdmin globaladmin = new SPGlobalAdmin();
// getting this Virtual Server
SPVirtualServer virtualserver =
globaladmin.OpenVirtualServer(uri1);
// getting the root url
string sRootUrl = virtualserver.Url.ToString();
Microsoft.SharePoint.Portal.Topology.TopologyManager
tm = new
Microsoft.SharePoint.Portal.Topology.TopologyManager();
Microsoft.SharePoint.Portal.Topology.PortalSite ps =
tm.PortalSites[new Uri(sRootUrl)];
PortalContext pc = PortalApplication.GetContext(ps);
//initialize user profile config manager object
Microsoft.SharePoint.Portal.UserProfiles.UserProfileManager
upm = new
Microsoft.SharePoint.Portal.UserProfiles.UserProfileManager(pc);
UserProfile userProfile =
upm.GetUserProfile(spc.CurrentUser.ToString());
string sName =
userProfile["PreferredName"].ToString();
string sEmail = userProfile["WorkEmail"].ToString();
string sID = spc.CurrentUser.ID.ToString();
spc = null;
globaladmin = null;
virtualserver = null;
tm = null;
ps = null;
upm = null;
userProfile = null;
As you can see the email address is the 'WorkEmail'
property in the UserProfile. If you click on the
'Manage Profile Database' the last option 'View
profile properties' you get an overview of ALL
properties.