none
Adding a user to a SharePoint Security Group in a claims authentication

    Question

  • Hi All,

    I have a SharePoint 2010 site with Siteminder claims enabled. I can add the users through PeoplePicker from sharepoint.

    My requirement is to add the users using e-mail id from a ASP.Net web application.

    Can anyone suggest me the approaches to add the user from ASP.Net? I thought of using the SharePoint web services or the client Object model to add the user. Will it work in a claims enabled site?

    Is there any other way to do this?

    Thank you.


    Kathir

    Friday, October 18, 2013 6:24 AM

Answers

All replies

  • Yes you can use Client Object  Model. Sample below.

    ClientContext clientContext = new ClientContext(siteUrl);
                Web web = clientContext.Web;
                User user = web.EnsureUser(@"domainName\userName");
                Group testingOwnersGroup = web.SiteGroups.GetById(6);
                UserCollection userCollection = testingOwnersGroup.Users;
                userCollection.AddUser(user);
                clientContext.Load(userCollection);               
                clientContext.ExecuteQuery(); 


    Bala

    Friday, October 18, 2013 6:32 AM
  • Hi Bala,

    Thanks for your reply. My SharePoint farm is running in claims. I do not have any domain names like "

    web.EnsureUser(@"domainName\userName");

    I can use only the email address to add the user.

    Can i use the email id in the above line?


    Kathir

    Friday, October 18, 2013 6:41 AM
  • Yes this works with Email ID.

    Bala

    Friday, October 18, 2013 6:52 AM
  • Let me check with this code and update you the outcome.


    Kathir

    Friday, October 18, 2013 6:56 AM
  • Hello,

    I don't think emailID will work with EnsureUser() method so try with UserCreationInformation class.

    http://msdn.microsoft.com/en-us/library/ee538244%28v=office.14%29.aspx


    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

    Monday, October 21, 2013 10:29 AM
  • Hemandra- 

    I tried EnsureUser() with email ID and it's working from my end. Did you face any issues in using it?


    Bala

    Tuesday, October 22, 2013 5:15 AM
  • The code is not working with a claims enabled site. Its working with SQL Membership based claims site.

    In my case we are using a third party custom claims provider and its not working.

    It says "Authorization failed" even if i pass the username password.


    Kathir

    Tuesday, October 29, 2013 10:38 AM
  • It seems there is problem with your third party claim provider so could you check with them?

    Since this code is working for SQL member so you should check with your vendor about this error. We are unknown about your third party tool.


    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

    Wednesday, November 06, 2013 5:23 AM