Click here to Skip to main content
15,993,913 members

Comments by gyana.dash123@gmail.com (Top 2 by date)

gyana.dash123@gmail.com 23-May-12 5:24am View    
Hi Sandeep,

Thanks for your reply.

I have changed my code still it is throughing access denied error. But when i run this code using central admin site its working fine. May be the problem is FBA authentication. If you have any solution please send it.

Below is my code:

SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite elevatedSite = new SPSite(SPContext.Current.Site.ID))
{
using (SPWeb web = elevatedSite.OpenWeb(SPContext.Current.Site.RootWeb.ID))
{
SPContentDatabase currentSiteDatabase = web.Site.ContentDatabase;

SPWebApplication elevatedWebApp = web.Site.WebApplication;
elevatedWebApp.ContentDatabases.Add(currentSiteDatabase.Server, dbName, null, null, 0, 1, 1);
}
}
});

Thanks
gyana.dash123@gmail.com 23-May-12 5:08am View    
Hi
I have changed my code still it is throughing access denied error. But when i run this code using central admin site its working fine.

Below is my code:

SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite elevatedSite = new SPSite(SPContext.Current.Site.ID))
{
using (SPWeb web = elevatedSite.OpenWeb(SPContext.Current.Site.RootWeb.ID))
{
SPContentDatabase currentSiteDatabase = web.Site.ContentDatabase;

SPWebApplication elevatedWebApp = web.Site.WebApplication;
elevatedWebApp.ContentDatabases.Add(currentSiteDatabase.Server, dbName, null, null, 0, 1, 1);
}
}
});