Welcome to MSDN Blogs Sign in | Join | Help

SharePoint : Add group of users to the user collection programmatically

The sample code as follows.

    SPWeb web = new SPSite("Site URL").OpenWeb();
    SPUserInfo[] userInfo = new SPUserInfo[1];
    userInfo[0].Email = "email@microsoft.com";
    userInfo[0].LoginName = @"domain\username";
    userInfo[0].Name = "username";
    userInfo[0].Notes = "Test";
    web.Roles["Reader"].Users.AddCollection(userInfo);

 

 

Published Thursday, March 16, 2006 6:17 PM by Karthikeyan
Filed under:

Comments

# http://live.com/

Wednesday, March 22, 2006 11:20 AM by TrackBack

# http://sharepoint.who.int/sites/intranet/sharepoint/default.aspx

Wednesday, March 22, 2006 11:20 AM by TrackBack

# http://sharepoint.who.int/sites/intranet/sharepoint/default.aspx

Wednesday, March 22, 2006 11:20 AM by TrackBack

# SPSite in client applications

Friday, May 25, 2007 4:12 PM by jhjzwart

Hello, I've made an outlook sharepoint integration on 1 machine. A BIG application. An Outlook Add-in project. Huge, and now I tried it on a clientmachine and I get the error when using theSite = SPSite(clsUtils.siteName) about not finding the file Microsoft.Sharepoint.intl. That file is not on my client computer. Don't tell me we can't use the SPSite en Web objects on client machines. What is the solution here?

# re: SharePoint : Add group of users to the user collection programmatically

Tuesday, October 23, 2007 11:49 AM by hoonius

Hi Karthick

Not sure if you still update this blog but i'm kinda desperate for some more info on this

I'm trying to add a user to a group but it keeps asking for a SharePoint administrator login when i try and add.  my SPWeb object has the correct profiles and when i spell the role incorrectly it gives me an error.  

It's just the AddUserToGroup function that is giving me the headache :¬(

any Ideas please?

cheers

Tim At Slashwoot dot Com

Anonymous comments are disabled
 
Page view tracker