Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulescreate new portal in custom modulecreate new portal in custom module
Previous
 
Next
New Post
4/23/2010 5:26 AM
 

Hi,

I'm building a module that can create a new portal (like the admin/portal module). So I checked how the portals module does that and used the same function: PortalController.CreatePortal(...).

But when I run this function I keep getting a security error, which I don't understand. Does anyone know what I'm doing wrong?

Error:

Error parsing Portal TemplateViolation of UNIQUE KEY constraint 'IX_FolderPermission'. Cannot insert duplicate key in object 'dbo.FolderPermission'.
The statement has been terminated.   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)

Code:
blnChild;string strPortalAlias;int intPortalId;string strServerPath;string strChildPath = "";PortalController objPortalController = new PortalController();//Portal Name

blnChild =

strPortalAlias =

strServerPath = DotNetNuke.Common.

 

false;"test213321414324";Globals.GetAbsoluteServerPath(Request);//Get Home Directory

 

 

 

string HomeDir = "";//Template

 

 

 

{

 

{

Templates.Add(

}

}

 

 

List<string> Templates = new List<string>();string[] fileEntries = System.IO.Directory.GetFiles(DotNetNuke.Common.Globals.HostMapPath, "*.template");foreach (string strFileName in fileEntries)if (Path.GetFileNameWithoutExtension(strFileName) != "admin")Path.GetFileNameWithoutExtension(strFileName));string strTemplateFile = Templates[0].ToString();//Create a user

 

objAdminUser.FirstName =

objAdminUser.LastName =

objAdminUser.Username =

objAdminUser.DisplayName =

objAdminUser.Email =

objAdminUser.IsSuperUser =

objAdminUser.Membership.Approved =

objAdminUser.Membership.Password =

objAdminUser.Membership.PasswordQuestion =

objAdminUser.Membership.PasswordAnswer =

objAdminUser.Profile.FirstName =

objAdminUser.Profile.LastName =

 

UserInfo objAdminUser = new UserInfo();"wimpie";"none";"wimpie2348798432";"wimpie2348798432";"willem@spam.la";false;true;"password1234";"question";"answer";"Wimpie";"None";//Create portal

intPortalId = objPortalController.CreatePortal(

"titlem321321", objAdminUser, "dsad", "adasd", DotNetNuke.Common.Globals.HostMapPath, strTemplateFile, HomeDir, strPortalAlias, strServerPath, strChildPath, blnChild);

 

bool

 

 

 

 

 

 

 
New Post
4/23/2010 7:20 AM
 

Better readable and complete code here:

bool blnChild;
string strPortalAlias;
int intPortalId;
string strServerPath;
string strChildPath = "";

PortalController objPortalController = new PortalController();

//Portal Name
blnChild = false;
strPortalAlias = "test213321414324";

strServerPath = DotNetNuke.Common.Globals.GetAbsoluteServerPath(Request);

//Get Home Directory
string HomeDir = "";

//Template
List Templates = new List();
string[] fileEntries = System.IO.Directory.GetFiles(DotNetNuke.Common.Globals.HostMapPath, "*.template");
foreach (string strFileName in fileEntries)
{
if (Path.GetFileNameWithoutExtension(strFileName) != "admin")
{
Templates.Add(Path.GetFileNameWithoutExtension(strFileName));
}
}
string strTemplateFile = Templates[0].ToString();

//Create a user
UserInfo objAdminUser = new UserInfo();

objAdminUser.FirstName = "wimpie";
objAdminUser.LastName = "none";
objAdminUser.Username = "wimpie2348798432";
objAdminUser.DisplayName = "wimpie2348798432";
objAdminUser.Email = "willem@spam.la";
objAdminUser.IsSuperUser = false;

objAdminUser.Membership.Approved = true;
objAdminUser.Membership.Password = "password1234";
objAdminUser.Membership.PasswordQuestion = "question";
objAdminUser.Membership.PasswordAnswer = "answer";

objAdminUser.Profile.FirstName = "Wimpie";
objAdminUser.Profile.LastName = "None";

//Create portal
intPortalId = objPortalController.CreatePortal("titlem321321", objAdminUser, "dsad", "adasd", DotNetNuke.Common.Globals.HostMapPath, strTemplateFile, HomeDir, strPortalAlias, strServerPath, strChildPath, blnChild);
 

 
New Post
4/26/2010 3:52 AM
 

I found it:

string

strTemplateFile = Templates[0].ToString();

should be this:

string

strTemplateFile = Templates[0].ToString() + ".template";

perhaps there should be a check if the file excists in the createportal function so there will be a more clear error?

 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulescreate new portal in custom modulecreate new portal in custom module


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out