I am trying to solve the following problem. We have a web app with multiple authentication methods (Windows, Forms and ADFS). With the usual ADFS deployment the People Picker will not resolve the names of users that login via ADFS. It will just accept any string that you type in.
In our environment we have a database table that stores all of the email address of the users regardless of the authentication method(Windows, Forms or ADFS).
I have created a Custom Claims Provider that searches the database and returns matching email addresses. I have deployed and the search works inside the People Picker. However, once you select the email address of the user and click OK to give them permissions I get an SPException: The user does not exist or is not unique.
Here's some of the code I'm using (BTW, the name of the custom claims provider is DOJCCP)
private PickerEntity GetPickerEntity(string claimValue, string displayName, string emailAddress, string jobTitle, string department, string pictureUrl)
{
try
{
PickerEntity pickerEntity = CreatePickerEntity();
pickerEntity.Claim = new SPClaim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress", emailAddress, Microsoft.IdentityModel.Claims.ClaimValueTypes.String,
SPOriginalIssuers.Format
(SPOriginalIssuerType.ClaimProvider,
"DOJCPP"));
pickerEntity.Description = this.Name + ":" + displayName;
pickerEntity.DisplayText = emailAddress;
pickerEntity.EntityData[PeopleEditorEntityDataKeys.Email] = emailAddress;
pickerEntity.EntityData[PeopleEditorEntityDataKeys.JobTitle] = jobTitle;
pickerEntity.EntityData[PeopleEditorEntityDataKeys.Department] = department;
if (string.Compare(pictureUrl, "N/A") != 0)
{
pickerEntity.EntityData["Picture"] = pictureUrl;
}
pickerEntity.Key = "c:05.c|DOJCCP|" + emailAddress;
pickerEntity.EntityType = SPClaimEntityTypes.User;
pickerEntity.IsResolved = true;
pickerEntity.EntityGroupName = "Users";
return pickerEntity;
}
catch (Exception ex)
{
throw new Exception("GetPickerEntity method has raised an exception " + ex.Message);
}
}
protected override void FillResolve(Uri context, string[] entityTypes, SPClaim resolveInput, List<PickerEntity> resolved)
{
try
{
if (EntityTypesContain(entityTypes, SPClaimEntityTypes.User))
{
if (resolveInput.ClaimType.ToLower() == EmailAddressClaimType.ToLower())
{
Helper ccpHelper = new Helper();
ArrayList resolvedUsers = ccpHelper.ResolveUser(resolveInput);
foreach (UserInfo resolvedUser in resolvedUsers)
{
PickerEntity pickerEntity = GetPickerEntity(resolvedUser.ClaimValue,
resolvedUser.DisplayName,
resolvedUser.EmailAddress,
resolvedUser.JobTitle,
resolvedUser.Department,
resolvedUser.PictureUrl);
pickerEntity.Key = "c:05.c|DOJCCP|" + resolvedUser.EmailAddress;
resolved.Add(pickerEntity);
}
}
}
}
catch (Exception ex)
{
throw new Exception("FillResolve:SPClaim method raised exception " + ex.Message);
}
}
protected override void FillResolve(Uri context, string[] entityTypes, string resolveInput, List<PickerEntity> resolved)
{
try
{
if (EntityTypesContain(entityTypes, SPClaimEntityTypes.User))
{
Helper ccpHelper = new Helper();
ArrayList resolvedUsers = ccpHelper.ResolveUser(resolveInput);
foreach (UserInfo resolvedUser in resolvedUsers)
{
PickerEntity pickerEntity = GetPickerEntity(resolvedUser.ClaimValue,
resolvedUser.DisplayName,
resolvedUser.EmailAddress,
resolvedUser.JobTitle,
resolvedUser.Department,
resolvedUser.PictureUrl);
pickerEntity.Key = "c:05.c|DOJCCP|" + resolvedUser.EmailAddress;
resolved.Add(pickerEntity);
}
}
}
catch (Exception ex)
{
throw new Exception("FillResolve:string method raised exception " + ex.Message);
}
}
Any ideas on how to debug this would be greatly appreciated.
thanks,