4

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,

  • Department of Justice? – RJ Cuthbertson Jul 11 '12 at 16:41
  • Diocese of Joliet – user9419 Jul 11 '12 at 19:56
1
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"));

You misspelled DOJCCP as DOJCPP. Start there.

  • I corrected the error but I still have the same problem. Thanks. – user9419 Jul 11 '12 at 20:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.