People picker field in sharepoint, CommaSeparatedAccounts as domain\\user

861 Views Asked by At

I have a people pickerfield in sharepoint. I expect to return its CommaSeparatedAccounts as domain\user.

But it returns CommaSeparatedAccounts' value as "i:0#.w|domain\user"

Find the code sample.

<%@ Register TagPrefix="spuc" Namespace="Microsoft.SharePoint.WebControls"
             Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<spuc:PeopleEditor ID="PeopleEditor1" runat="server"
                   AllowEmpty="true" MultiSelect="false" SelectionSet="User"  />
1

There are 1 best solutions below

0
Aarti On BEST ANSWER

It will give you the login name in the same format. But you can decode this in your code behind.

Use the following code to decode the username :

string userName = null;
SPClaimProviderManager mgr = SPClaimProviderManager.Local;
if (mgr != null)
{
    userName = mgr.DecodeClaim(SPContext.Current.Web.CurrentUser.LoginName).Value;
}