Tuesday, August 9, 2011

The user does not exist or is not unique FBA while adding AdGroup to siteGroup SharePoint 2010

Hi

I tried to add an ADGroup/FBARole to  site  group . In 2 ways:

1 is AddUser(SPUser user);

2nd is AddUser(string loginName, string email, string name, string notes)

code for 1st option:

SPUser cntrSubSiteUser = CreateUser(Constants.C_FBA_AUTHENTICATION_GROUP_PREFIX + RoleProvider + Constants.C_AUTHENTICATION_PIPE + ADgroup, "", ADgroup, "", web.Site);//loginname in format in format c:0-.f|roleproviderName|pp 1001 siteGroup.AddUser(cntrSubSiteUser);

siteGroup.Update();

and the createuser function is like;

private static SPUser CreateUser(string strLoginName, string strEMail, string strName, string strNotes, SPSite spSite) { SPUser spReturn = null; SPRoleAssignment spRoleAssignment = new SPRoleAssignment(strLoginName, strEMail, strName, strNotes); SPRoleDefinition spSPRoleDefinition = spSite.RootWeb.RoleDefinitions["Read"]; spRoleAssignment.RoleDefinitionBindings.Add(spSPRoleDefinition); spSite.RootWeb.RoleAssignments.Add(spRoleAssignment); //Update site spSite.RootWeb.Update(); spReturn = spSite.RootWeb.AllUsers[strLoginName]; return spReturn; }

 

for the second option code is like:- siteGroup.AddUser(Constants.C_FBA_AUTHENTICATION_GROUP_PREFIX + RoleProvider + Constants.C_AUTHENTICATION_PIPE + ADgroup, "", ADgroup, "");//Login Name in format c:0-.f|amsurgrole|pp 1001

siteGroup.Update();

 

 

 

Now lets come to the problem:

On 1 of our dev servers it works fine. But on production we get the error: The user does not exist or is not unique

However by UI, We can add this FBA Role  to any group.

 

please help.

 

Reply 1


hi

 

we have got the solution.

 

we are adding user in group for site 1( on web app 1) from site 2 ( on web app 2) code.  web app 1 is FBA .  site 2 is normal windows site.

in 2007 this code works fine

 

but for sharepoint 2010, we need to give entries for roleprovider and membership provider in web application 2 (admin web app) web.config  also.

                                                                      Reply 1.1


 I  am also getting the same exception. I am doing everything on a single sharepoint application

[SPException: The user does not exist or is not unique.]

 

Can you please point out, what are the other scenarios for the exception to happen?

Reply 1.1.1

did u also do ensure user ? also make sure user exists in ad/ ur membership provider

Reply 1.1.1.1

when extending the application it named the membership provider wrongly, hence the error is caused. Thanks for all the replies. Now the problem is solved.

No comments:

Post a Comment