Ectropy
Ectropy

Reputation: 1541

What does get_fieldValues().Name return for a siteUserInfoList item

I'm trying to confirm that my understanding of the results of get_fieldValues().Name in SharePoint is correct.

When I use the following code:

var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef Name=\'ID\'/>' +'<Value Type=\'Number\'>' + managerId + '</Value></Eq>' +'</Where></Query><RowLimit>1</RowLimit></View>');

var userInfoList = hostweb.get_siteUserInfoList();
var collListItem = userInfoList.getItems(camlQuery);

currentContext.load(collListItem);  
currentContext.executeQueryAsync(onQuerySucceeded,onQueryFailed);

function onQuerySucceeded(sender, args) 
{   
var item = collListItem.itemAt(0);

var userInfo = item.get_fieldValues().Name;
}

I get a string that looks like this as a result:

i:0#.f|membership|[email protected]

As I understand it, this is split into 3 parts separated by bars/pipes.

I don't know what the first part i:0#.f is, but I'm not making use of it so it's not super-important.

The second part seems to be a category or group of users membership, I'm not making use of this either.

The third seems to be an email address for the user or maybe a login name [email protected].

My question is, could this third part ever be something that is not an email address? For my organization it seems that this section is always an email address. As such I'm using it to find the email address for particular users, and it's working fine. The problem is the app I'm developing may be used by other organizations, and I'm worried that for some other organizations that section will not contain an email, and instead something else. If that is the case, I'll be retrieving something that isn't an email address, and trying to send emails to it--which would be a problem, and break certain parts of my code.

Upvotes: 0

Views: 1792

Answers (1)

Vadim Gremyachev
Vadim Gremyachev

Reputation: 59348

Starting with SharePoint 2010 Claims Based Authentication is supported in SharePoint. In Claims Based Authentication mode account name is represented in the following format:

<IdentityClaim>:0<ClaimType><ClaimValueType><AuthMode>|<OriginalIssuer (optional)>|<ClaimValue>

Please refer SharePoint 2013: Claims Encoding - Also Valuable for SharePoint 2010 article for an explanation of claim format.

In your case Forms-based authentication type of claim is used where:

  • i for an identity claim
  • # for the user logon name format for the claim value
  • . for string
  • f for forms-based authentication
  • membership identifies the original issuer of the identity claim
  • [email protected] for the claim value. It could be represented not only as email address

For retrieving email address from User Information List you could use the corresponding Email property:

var email = item.get_fieldValues().EMail;

References

SharePoint 2013: Claims Encoding - Also Valuable for SharePoint 2010

Upvotes: 1

Related Questions