Creating SharePoint sites programmatically in MOSS 2007
2006-07-27 10:24
435 查看
At first, I want to build a registering webpart. When the user register in my TopLevel Site, he will be added into my siteuser list and the system will create a subsite for him.
So in the CreateUserWizard_CreatedUser method I add some code like:
CreateComSites();//create a subsite
SetUserToTopSiteVisitor();//add the new user to topsite visitor group
SetUserToSubSiteAdmin();//add the new user to the subsite(which we created above) owner group
I use the CreateUserWizard control for registering.
But the problem is, when the user visit the site at first time, he is anonymous. So after he click register button, the page will redirect to the login.aspx. And all of the code will not execute.
So my second plan is to build a individual asp.net site to manage the registering.
The code is very simple:
create a SPWeb instance of the TopLevel Site, use the SPWebCollecation.Add method.
It works excellently when the site is AD authentication.
And when I configure the site to form authentication, problem appears:
Sometimes I can create the subsite successfully though some exception catched.(when in AD authentication, it's the same)
Sometimes some exception catched with the same beginning with the above paragraphs such as
"System.NullReferenceException: Object reference not set to an instance of an object."
but different in detailed information.
I will show you the two exception:
1.the site created successfully in AD or Form.
System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.SharePoint.SPSite.get_Features() at Microsoft.SharePoint.SPElementProvider.QueryForWorkflowDefinitions(SPWeb web) at Microsoft.SharePoint.Workflow.SPWorkflowManager.RegisterFeatureTemplates(SPWorkflowTemplateCollection wftemplates, SPWeb web) at Microsoft.SharePoint.SPWeb.get_WorkflowTemplates() at Microsoft.SharePoint.Workflow.SPWorkflowAssociation.get_BaseTemplate() at Microsoft.SharePoint.Workflow.SPWorkflowAssociation.get_BaseTemplateInternal() at Microsoft.SharePoint.Workflow.SPWorkflowAssociation.SetTaskList(SPList list) at Microsoft.SharePoint.Workflow.SPWorkflowAssociationCollection.SetUtilityLists(SPWorkflowAssociation wa, Boolean forceUtilityListCreation) at Microsoft.SharePoint.Workflow.SPWorkflowAssociationCollection.AddCore(SPWorkflowAssociation wa, Guid id, SPList list, Boolean forceUtilityListCreation) at Microsoft.SharePoint.Workflow.SPContentTypeWorkflowAssociationCollection.AddCoreCT(SPWorkflowAssociation associationTemplate) at Microsoft.SharePoint.Workflow.SPContentTypeWorkflowAssociationCollection.UpdateOrAdd(SPWorkflowAssociation associationTemplate) at Microsoft.SharePoint.SPContentType.CopyWorkflowAssociationsTo(SPContentType ctDst) at Microsoft.SharePoint.SPWeb.SyncNewLists() at Microsoft.SharePoint.SPWeb.ApplyWebTemplate(String strWebTemplate) at Microsoft.SharePoint.SPSite.CreateWeb(String strUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean bCreateUniqueSubweb, Boolean bConvertIfThere, Guid webId, Guid rootFolderId, Boolean createSystemCatalogs) at Microsoft.SharePoint.SPSite.SPWebCollectionProvider.CreateWeb(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean bCreateUniqueSubweb, Boolean bConvertIfThere) at Microsoft.SharePoint.SPWebCollection.Add(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean useUniquePermissions, Boolean bConvertIfThere) at _Default.Button1_Click(Object sender, EventArgs e)
2 .the site not created in Form
System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.SharePoint.Utilities.SPUtility.RedirectToAccessDeniedPage(HttpContext context) at Microsoft.SharePoint.Utilities.SPUtility.HandleAccessDenied(Exception ex) at Microsoft.SharePoint.SPGlobal.HandleUnauthorizedAccessException(UnauthorizedAccessException ex) at Microsoft.SharePoint.Library.SPRequest.CreateWeb(String bstrUrl, String bstrTitle, String bstrDescription, UInt32 nLCID, String bstrWebTemplate, Boolean bCreateUniqueWeb, Boolean bConvertIfThere, Guid& pgWebId, Guid& pgRootFolderId, Boolean bCreateSystemCatalogs) at Microsoft.SharePoint.SPSite.CreateWeb(String strUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean bCreateUniqueSubweb, Boolean bConvertIfThere, Guid webId, Guid rootFolderId, Boolean createSystemCatalogs) at Microsoft.SharePoint.SPSite.SPWebCollectionProvider.CreateWeb(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean bCreateUniqueSubweb, Boolean bConvertIfThere) at Microsoft.SharePoint.SPWebCollection.Add(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean useUniquePermissions, Boolean bConvertIfThere) at _Default.Button1_Click(Object sender, EventArgs e) in
If anyone know how to handle it or anyone meets the same problem, let me know.
So in the CreateUserWizard_CreatedUser method I add some code like:
CreateComSites();//create a subsite
SetUserToTopSiteVisitor();//add the new user to topsite visitor group
SetUserToSubSiteAdmin();//add the new user to the subsite(which we created above) owner group
I use the CreateUserWizard control for registering.
But the problem is, when the user visit the site at first time, he is anonymous. So after he click register button, the page will redirect to the login.aspx. And all of the code will not execute.
So my second plan is to build a individual asp.net site to manage the registering.
The code is very simple:
create a SPWeb instance of the TopLevel Site, use the SPWebCollecation.Add method.
It works excellently when the site is AD authentication.
And when I configure the site to form authentication, problem appears:
Sometimes I can create the subsite successfully though some exception catched.(when in AD authentication, it's the same)
Sometimes some exception catched with the same beginning with the above paragraphs such as
"System.NullReferenceException: Object reference not set to an instance of an object."
but different in detailed information.
I will show you the two exception:
1.the site created successfully in AD or Form.
System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.SharePoint.SPSite.get_Features() at Microsoft.SharePoint.SPElementProvider.QueryForWorkflowDefinitions(SPWeb web) at Microsoft.SharePoint.Workflow.SPWorkflowManager.RegisterFeatureTemplates(SPWorkflowTemplateCollection wftemplates, SPWeb web) at Microsoft.SharePoint.SPWeb.get_WorkflowTemplates() at Microsoft.SharePoint.Workflow.SPWorkflowAssociation.get_BaseTemplate() at Microsoft.SharePoint.Workflow.SPWorkflowAssociation.get_BaseTemplateInternal() at Microsoft.SharePoint.Workflow.SPWorkflowAssociation.SetTaskList(SPList list) at Microsoft.SharePoint.Workflow.SPWorkflowAssociationCollection.SetUtilityLists(SPWorkflowAssociation wa, Boolean forceUtilityListCreation) at Microsoft.SharePoint.Workflow.SPWorkflowAssociationCollection.AddCore(SPWorkflowAssociation wa, Guid id, SPList list, Boolean forceUtilityListCreation) at Microsoft.SharePoint.Workflow.SPContentTypeWorkflowAssociationCollection.AddCoreCT(SPWorkflowAssociation associationTemplate) at Microsoft.SharePoint.Workflow.SPContentTypeWorkflowAssociationCollection.UpdateOrAdd(SPWorkflowAssociation associationTemplate) at Microsoft.SharePoint.SPContentType.CopyWorkflowAssociationsTo(SPContentType ctDst) at Microsoft.SharePoint.SPWeb.SyncNewLists() at Microsoft.SharePoint.SPWeb.ApplyWebTemplate(String strWebTemplate) at Microsoft.SharePoint.SPSite.CreateWeb(String strUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean bCreateUniqueSubweb, Boolean bConvertIfThere, Guid webId, Guid rootFolderId, Boolean createSystemCatalogs) at Microsoft.SharePoint.SPSite.SPWebCollectionProvider.CreateWeb(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean bCreateUniqueSubweb, Boolean bConvertIfThere) at Microsoft.SharePoint.SPWebCollection.Add(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean useUniquePermissions, Boolean bConvertIfThere) at _Default.Button1_Click(Object sender, EventArgs e)
2 .the site not created in Form
System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.SharePoint.Utilities.SPUtility.RedirectToAccessDeniedPage(HttpContext context) at Microsoft.SharePoint.Utilities.SPUtility.HandleAccessDenied(Exception ex) at Microsoft.SharePoint.SPGlobal.HandleUnauthorizedAccessException(UnauthorizedAccessException ex) at Microsoft.SharePoint.Library.SPRequest.CreateWeb(String bstrUrl, String bstrTitle, String bstrDescription, UInt32 nLCID, String bstrWebTemplate, Boolean bCreateUniqueWeb, Boolean bConvertIfThere, Guid& pgWebId, Guid& pgRootFolderId, Boolean bCreateSystemCatalogs) at Microsoft.SharePoint.SPSite.CreateWeb(String strUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean bCreateUniqueSubweb, Boolean bConvertIfThere, Guid webId, Guid rootFolderId, Boolean createSystemCatalogs) at Microsoft.SharePoint.SPSite.SPWebCollectionProvider.CreateWeb(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean bCreateUniqueSubweb, Boolean bConvertIfThere) at Microsoft.SharePoint.SPWebCollection.Add(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean useUniquePermissions, Boolean bConvertIfThere) at _Default.Button1_Click(Object sender, EventArgs e) in
If anyone know how to handle it or anyone meets the same problem, let me know.
相关文章推荐
- 转:How to create your own custom 404 error page and handle redirect in SharePoint 2007 (MOSS)?
- Enabling .NET 3.5 in SharePoint 2007 Sites, the Lazy Way{转载}
- How to create your own custom 404 error page and handle redirect in SharePoint 2007 (MOSS)?
- Enabling .NET 3.5 in SharePoint 2007 Sites, the Lazy Way{转载}
- Creating and Using a New Content Type in SharePoint 2007(zhuan:http://www.sharepointproconnections.com/article/sharepoint-portal
- Moss 2007 send email to AD group 和SharePoint Group
- Building Document Workflows in SharePoint 2007 翻译
- Creating a SharePoint BCS .NET Connectivity Assembly to Crawl RSS Data in Visual Studio 2010
- Creating a New Master Page in SharePoint 2013
- MOSS / Sharepoint 2007 Custom Error Page and Access denied Page
- MOSS 2007 模板部署Sharepoint Services Administration没有启动问题
- Microsoft SharePoint: Building Office 2007 Solutions in VB 2005
- Creating a Custom SharePoint 2007 List Definition
- Moving from design to reality - building HedKandi.com in Microsoft Office SharePoint Server 2007
- [Forward]Visual Guide: Setting up My Sites in SharePoint 2013
- Some useful links about MOSS 2007 && Sharepoint 2007
- MOSS与SharePoint Designer 2007
- Building Document Workflows in SharePoint 2007 翻译
- Creating a Custom Page Layout in SharePoint 2013
- Making the Newsfeed web part available outside of My Sites in SharePoint 2013 分类: Sharepoint 2015-07-07 19:29 4人阅读 评论(0) 收藏