Revision: 21686
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 18, 2009 10:52 by blackf0rk
Initial Code
//get a handle on our sites and web(s)
SPSite Site = new SPSite("<sharepoint url>");
SPWeb Web = Site.OpenWeb();
//get a handle on our current users (if any):
SPUserCollection users = Web.AllUsers;
//add the new user (see my snippet on getting users from Active Directory, which comes in handy here)
users.Add("<login name>", "<email address>", "<name>", "<notes>");
//no need to do an .update()
//you can now return this user as an SPUser:
SPUser newUser = users["<login name>"];
Initial URL
Initial Description
Initial Title
Add user to SharePoint
Initial Tags
directory, user, sharepoint
Initial Language
C#