mardi 2 décembre 2014

Unauthorized access exception when trying to create site collection with fba site collection administrator user?



The following code is used for site collection creation, the code is fine and it is working with no problems with site collection administrator (windows account) .

I tried to add fba user to the site collection administrators , when this user tried to run the following the code , Unauthorized access exception is thrown



SPSite newSite=null;
SPSecurity.RunWithElevatedPrivileges(() =>
{


using (SPSite site = new SPSite(SPContext.Current.Site.ID))
{

newSite = site.WebApplication.Sites.Add(
siteUrl: txtURL.Text,
title: txtTitle.Text,
description: txtDescription.Text,
nLCID: uint.Parse(ddlLanguages.SelectedValue),
webTemplate: site.RootWeb.WebTemplate,
ownerLogin: site.RootWeb.SiteAdministrators[0].LoginName,
ownerName: site.RootWeb.SiteAdministrators[0].Name,
ownerEmail: site.RootWeb.SiteAdministrators[0].Email,
secondaryContactEmail: null,
secondaryContactLogin: null,
secondaryContactName: null,
useHostHeaderAsSiteName: chkUseHostName.Checked
);

}
}


thanks alot for your help .








0 commentaires:

Enregistrer un commentaire