471,119 Members | 1,515 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,119 software developers and data experts.

Sharepoint: Issue Adding SPUser to SPGroup FBA & Windows Auth

Foreword: Our Sharepoint site runs off both Forms Based and Windows Authentication. That being said some users have dual accounts for both methods of authentication...but not all users. Each account has unique ID's but runs off different SSPs.

Problem: Currently working on a tool that one piece (the one I need help with) is having issues adding users to a specified SharePoint group. I am getting a legitimate SPUser but when I try to add that SPUser to the SPGroup it throws an error whenever that SPUser is an AD SPUser as opposed to one from the Forms-Based Authentication.

Expand|Select|Wrap|Line Numbers
  1.     protected void AddUserToGroup(string strUserName)
  2.     {
  3.       SPWeb oWeb = SPContext.Current.Web;
  4.       SPUser oUser = getSPUser(strUserName);
  5.       if (oUser != null)
  6.       {
  7.         oWeb.AllowUnsafeUpdates = true;
  8.         SPGroup oCurrentGroup = oWeb.Groups[gstrListGroup];
  9.         lblStatus.Text += oUser.Name + ": ";
  10.         try
  11.         {
  12.           oCurrentGroup.AddUser(oUser);
  13.           lblStatus.Text += "Complete<br>";
  14.         }
  15.         catch (Exception)
  16.         {
  17.           lblStatus.Text += "Error occured. Please check the name or add the user via the Sharepoint Group<br>";
  18.         }
  19.         finally
  20.         {
  21.           oCurrentGroup.Update();
  22.         }
  23.         oWeb.AllowUnsafeUpdates = false;
  24.       }
  25.     }
I have also tried to hard-code manually add the AD account and I still get the error. It tells me that the user is not unique or does not exist which does not make any sense to me because when I go to SharePoint directly I see the SPUser, I see their properties and their unique ID.

Could this possibly be a case where if the user may no longer exist in AD but still has a SharePoint account that they may be throwing this error?
Oct 15 '09 #1
2 5278
Even I am geting same issue. Any solution?
Sep 29 '10 #2
Did you ever figure this out? I'm using PowerShell and getting a similar result: Set-SPUser : The user does not exist or is not unique.
Dec 21 '15 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Michael S | last post: by
reply views Thread by Chris Mohan | last post: by
1 post views Thread by Fao, Sean | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.