Automate SharePoint site creation
hello,
i want to ask if their is a way to automate page creation in a site...
lets say if i add a user to my "Projects" site a page is created for that particular user automatically by SharePoint...
if its possible do i need FBA or simple windows authentication...?
thanks...
May 2nd, 2010 7:06pm
Assuming: "user" is a user already in your Active Directory or your FBA database, and "page" is a page in a library...
1) You could create an ASPX page to do this user administration and when you add a new user use the SharePoint API to add the user to the site directly (or better, to a group) and then using code add the page for the user. Windows authentication will
still work ok.
2) You could also create a custom list where you add new users. This list would have an event receiver that would fire when new users are added that would though the API would add the user to the appropriate site/group and create the new page.
Mike Smith TechTrainingNotes.blogspot.com
Free Windows Admin Tool Kit Click here and download it now
May 2nd, 2010 8:17pm
thanx for the reply Mike...can u refer to any links or help material on this ?...thanks
May 2nd, 2010 10:03pm
I'll see if I can find some resources. Most available would be pretty general on creating pages and event receivers.
Two questions...
Are you a .Net developer? (You posted this in Setup, Upgrade, Administration and Operation)
Are you permitted to deploy files to the web front end servers?
My two proposals cannot be done with SharePoint Designer.
Mike Smith TechTrainingNotes.blogspot.com
Free Windows Admin Tool Kit Click here and download it now
May 2nd, 2010 11:19pm
yes i am...that happened by mistake, i have a slow internet connection i mistakenly clicked on the setup, upgrade option forgot that i already clicked on the development and programming choice before the page refreshed.
i have my SharePoint installation on a VPC with windows 2008 server enterprise and i have no WFE's, im just using it for testing, so their is no issue for deploying files in any circumstances.
May 2nd, 2010 11:35pm
Here's a start:
For the event receiver approach...
How to create an event receiver and deploy it:
http://msdn.microsoft.com/en-us/library/ms453149.aspx
http://developers.de/blogs/adis_jugo/archive/2009/03/12/develop-and-deploy-a-sharepoint-event-receiver-from-the-scratch.aspx
GoogleBing "sharepoint event receiver" for more articles
How to create users...
In SharePoint you add users to a Site Collection, and grant them permissions to sites, lists, libraries, folders and items.
To add a user to a site collection (and there are many ways to do this):
web.SiteUsers.Add("maxsp2007\\smithb", "smithb@maxtrain.local", "Bob Smith", "These are notes");
"web" is the current web site, or the top level web site in the site colleciton
see: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.siteusers.aspx
see: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spusercollection.add%28v=office.12%29.aspx
To add a user to a group:
SPUser user = web.SiteUsers.GetCollection(new string[] {"MAXSP2007\\smithb"})[0];
// or SPUser user = web.SiteUsers.GetByEmail("smithb@maxtrain.local");
SPGroup grp = web.SiteGroups["Training Members"];
grp.AddUser(user);
To add permissions to a user (to a web in this example):
SPUser user = web.AllUsers["maxsp2007\\pavelb"];
SPRoleAssignment roleAssignment = new SPRoleAssignment(user);
SPRoleDefinitionBindingCollection definitions = roleAssignment.RoleDefinitionBindings;
definitions.Add(web.RoleDefinitions["Read"]); <-- name of Permission Level
web.RoleAssignments.Add(roleAssignment);
Other good to knows...
How to use code behind with Site Pages (Content pages)
http://www.andrewconnell.com/blog/articles/UsingCodeBehindFilesInSharePointSites.aspx
Mike Smith TechTrainingNotes.blogspot.com
Free Windows Admin Tool Kit Click here and download it now
May 3rd, 2010 1:05am