Writing a Custom Claims Provider for SharePoint 2010 – Part 4: Supporting Resolve Name

In the first three parts of this series we’ve implemented just about all of the support needed to do an end-to-end claims provider.  In this last post I’ll describe how to name resolution support in the type-in control.  To add this support we’ll need to implement the following property and methods:  SupportsResolve and FillResolve.  Now the good news is that I already covered how to implement SupportsResolve and one of the FillResolve overloads in part 3.  So this posting will be pretty short – here’s the implementation for the other overload of FillResolve that was not covered in part 3:

protected override void FillResolve(Uri context, string[] entityTypes,

      string resolveInput,

      List<Microsoft.SharePoint.WebControls.PickerEntity> resolved)

{

 

//make sure picker is asking for the type of entity we

//return; site collection admin won’t for example

if (!EntityTypesContain(entityTypes, SPClaimEntityTypes.FormsRole))

      return;

 

//same sort of code as in search to validate we have a match

foreach (string team in ourTeams)

{

      if (team.ToLower() == resolveInput.ToLower())

      {

            //we have a match, create a matching entity

            PickerEntity pe = GetPickerEntity(team);

 

            //add it to the return list of picker entries

            resolved.Add(pe);

       }

}

}

 

If you’ve been following along then this chunk of code should be completely straightforward.  If it isn’t, then read through part 3 again. 

We are now code complete.  If I bring up the type-in control and enter a team name and then click the resolve button, here’s what it looks like – first when you type it in, and then after clicking the resolve button:

And with that, we’re done.  Hopefully you will find this information useful as you start building out your claims authentication plans.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s