in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

helloibm

Programmatically adding a SiteCollection with custom membership provider

SPWebApplication.Sites.Add should be an easy function to call. Among the parameters is ownerLogin. This works a charm when your web application is configured for the default windows authentication. But in my case it was a custom membership provider. I tried several times to do it while specifying membershipprovider:ownername. BUT it continuously gives "User cannot be found".

At the end i had to resort to the Admin.asmx web service. It provides us a CreateSite function with almost the same functionlity as the SPWebApplication.Sites.Add(). The only catch here is that this method will only work on the central admin web application. You cannot use it on any content applications. ( REF: WSS SDK Admin::CreateSite )

So here is how i ended up solving my problem

//Create an instance of the Central Admin web service
_Admin.Admin _adm = new _Admin.Admin();
           
 //Get the url for the Admin site.
string caURL = System.Configuration.ConfigurationSettings.AppSettings["centralAdminApplicationURL"].ToString();
           
//set the URL to the "REQUIRED" central admin site
_adm.Url = caURL + "/_vti_adm/admin.asmx";

//Prefix the membership provider name to the ownerlogin.
string provider = System.Configuration.ConfigurationSettings.AppSettings["membershipProviderKey"].ToString();
ownerLogin = provider + ":" + ownerLogin;
           
//set the credentials for current web service call.
_a.Credentials = new System.Net.NetworkCredential("user", "password", "DOMAIN");
_a.CreateSite(siteCollURL, title, description, langID, template, ownerLogin, ownerName, ownerEmail, "", "");            

Comments

 

Links (1/15/2008) « Steve Pietrek’s SharePoint Stuff said:

Pingback from  Links (1/15/2008) « Steve Pietrek’s SharePoint Stuff

January 15, 2008 8:40 PM
 

Ariel said:

that user cannot be found msg may be coming because you were not specifying a prefix needed for custom membership providers, like

Passport:pepino@hotmail.com

September 2, 2008 12:32 PM

Leave a Comment

(required )  
(optional )
(required )  
Add

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts