The dirty world of SharePoint programming
Sometimes SharePoint drives you mad. Case of today:
accountname=....
guid=...
sid=...
preferredname=...
Make a page: GetProfileProperty.aspx
<%@ Register Tagprefix="SharePoint"
Namespace="Microsoft.SharePoint.WebControls"
Assembly="Microsoft.SharePoint, Version=11.0.0.0,
Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SPSWC"
Namespace="Microsoft.SharePoint.Portal.WebControls"
Assembly="Microsoft.SharePoint.Portal, Version=11.0.0.0,
Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<SPSWC:ProfilePropertyLoader runat="server" />
<SPSWC:ProfilePropertyValue
PropertyName="AccountName" ApplyFormatting="false"
runat="server" />
Call it like GetProfileProperty.aspx?accountname=domain\user
In the sample code the AccountName is returned, but you can use any property name, or even make the property itself a parameter.
In your code you have to execute a call to the page using the WebRequest class. The result is the property value in plain text.It is an extra roundtrip, but sometimes you don't have many alternatives...