Why does SPWeb.EnsureUser() return false for CBA user?

I've got a CBA login represented by the following string:

"-1;#i:0#.w|YYY-test\\sxe1444,#i:0#.w|YYY-test\\sxe1444,#SSS.EEE@YYY.com,#SSS.EEE@YYY.com,#EEE, SSS (Contractor),#,#,#"

The user definitely exists on that SPWeb, but when it comes to call

spWeb.EnsureUser("-1;#i:0#.w|YYY-test\\sxe1444,#i:0#.w|YYY-test\\sxe1444,#SSS.EEE@YYY.com,#SSS.EEE@YYY.com,#EEE, SSS (Contractor),#,#,#")

I get an exception telling there's no such user known for Sharepoint. Moreover, when I call SPClaimProviderManager.IsEncodedClaim(), it returns false for that user's login. I'd like to know what I'm doing wrong and how to retrieve the Windows domain user login from such string.

June 6th, 2014 3:13pm

at the following post you can understand CBA format

http://www.wictorwilen.se/Post/How-Claims-encoding-works-in-SharePoint-2010.aspx

hope it helps

Free Windows Admin Tool Kit Click here and download it now
June 6th, 2014 7:01pm

Hi,

Thanks for the link, it might be useful when it comes to Regex-based parsing for that string, but I'd like to know why Sharepoint doesn't recognize its own login presentation. As I've already told , the SPClaimProviderManager.IsEncodedClaim() call returns false. And moreover, the code:

                    SPClaimProviderManager mgr = SPClaimProviderManager.Local;
                    var b1 = SPClaimProviderManager.IsEncodedClaim(ul);

                    if (mgr != null && b1)
                    {
                        var dd = mgr.DecodeClaim(ul);
                        userName = dd.Value;
                        // here userName contains "YYY-test\\sxe1444,#SSS.EEE@YYY.com,#SSS.EEE@YYY.com,#EEE, SSS (Contractor),#,#,#"
                        SPUser su = web.EnsureUser(userName);
                    }
throws "User not found" exception? Is there any API-supported way of getting "YYY-test\\sxe1444" from userName (aside from Regex parsing)?


June 7th, 2014 3:50pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics