Error Creating Site Collection Programmatically
I have a console application that is going to be used to parse an input file and create site collections based on the input. It is being run on a WFE in the farm, by a farm admin account. When attempting to add a site collection to a web application with a valid user an ArgumentException is thrown deep in the stack with an error message of "0x80070057". I have verified that if an invalid account is used the correct SPException indicating that the user is not found is thrown, and that all other parameters are correct.
Code:
internal static void CreateOrgSite(String path)
{
SPWebApplication webApp = SPWebApplication.Lookup(new Uri(ConfigurationManager.AppSettings["WebAppBaseUrl"]));
String user = Environment.UserDomainName + "\\" + Environment.UserName;
String newSiteUrl = GetCompleteUrl(path);
webApp.Sites.Add(newSiteUrl, user, String.Empty);
}
Stack Trace:
System.ArgumentException: <nativehr>0x80070057</nativehr><nativestack></nativestack>
at Microsoft.SharePoint.Library.SPRequestInternalClass.OpenWebInternal(String bstrUrl, Guid& pguidID, String& pbstrRequestAccessEmail, UInt32& pwebVersion, String& pbstrServerRelativeUrl, UInt32& pnLanguage, UInt32& pnLocale, String& pbstrDefaultTheme, String& pbstrDefaultThemeCSSUrl, String& pbstrThemedCssFolderUrl, String& pbstrAlternateCSSUrl, String& pbstrCustomizedCssFileList, String& pbstrCustomJSUrl, String& pbstrAlternateHeaderUrl, String& pbstrMasterUrl, String& pbstrCustomMasterUrl, String& pbstrSiteLogoUrl, String& pbstrSiteLogoDescription, Object& pvarUser, Boolean& pvarIsAuditor, Int32& plSiteFlags, Boolean& pbOverwriteMUICultures, Boolean& pbMUIEnabled, String& pbstrAlternateMUICultures, Int32& puiVersion, Int16& pnClientTag)
at Microsoft.SharePoint.Library.SPRequest.OpenWebInternal(String bstrUrl, Guid& pguidID, String& pbstrRequestAccessEmail, UInt32& pwebVersion, String& pbstrServerRelativeUrl, UInt32& pnLanguage, UInt32& pnLocale, String& pbstrDefaultTheme, String& pbstrDefaultThemeCSSUrl, String& pbstrThemedCssFolderUrl, String& pbstrAlternateCSSUrl, String& pbstrCustomizedCssFileList, String& pbstrCustomJSUrl, String& pbstrAlternateHeaderUrl, String& pbstrMasterUrl, String& pbstrCustomMasterUrl, String& pbstrSiteLogoUrl, String& pbstrSiteLogoDescription, Object& pvarUser, Boolean& pvarIsAuditor, Int32& plSiteFlags, Boolean& pbOverwriteMUICultures, Boolean& pbMUIEnabled, String& pbstrAlternateMUICultures, Int32& puiVersion, Int16& pnClientTag)
at Microsoft.SharePoint.SPWeb.InitWebPublic()
at Microsoft.SharePoint.SPWeb.get_ServerRelativeUrl()
at Microsoft.SharePoint.SPWeb.get_Url()
at Microsoft.SharePoint.SPUser.InitMember()
at Microsoft.SharePoint.SPUser..ctor(SPWeb web, SPSecurableObject scope, String strIdentifier, Object[,] arrUsersData, UInt32 index, Int32 iByParamId, String strByParamSID, String strByParamEmail, SPUserCollectionType userCollectionType, Boolean isSiteAuditor)
at Microsoft.SharePoint.SPUser..ctor(SPWeb web, SPSecurableObject scope, String strIdentifier, Object[,] arrUsersData, UInt32 index, Int32 iByParamId, String strByParamSID, String strByParamEmail, SPUserCollectionType userCollectionType)
at Microsoft.SharePoint.SPUserCollection.GetByLoginNoThrow(String loginName)
at Microsoft.SharePoint.SPUserCollection.get_Item(String loginName)
at Microsoft.SharePoint.Administration.SPSiteCollection.Add(SPContentDatabase database, SPSiteSubscription siteSubscription, String siteUrl, String title, String description, UInt32 nLCID, String webTemplate, String ownerLogin, String ownerName, String ownerEmail, String secondaryContactLogin, String secondaryContactName, String secondaryContactEmail, String quotaTemplate, String sscRootWebUrl, Boolean useHostHeaderAsSiteName)
at Microsoft.SharePoint.Administration.SPSiteCollection.Add(SPSiteSubscription siteSubscription, String siteUrl, String title, String descripti开发者_JS百科on, UInt32 nLCID, String webTemplate, String ownerLogin, String ownerName, String ownerEmail, String secondaryContactLogin, String secondaryContactName, String secondaryContactEmail, Boolean useHostHeaderAsSiteName)
at Microsoft.SharePoint.Administration.SPSiteCollection.Add(String siteUrl, String title, String description, UInt32 nLCID, String webTemplate, String ownerLogin, String ownerName, String ownerEmail, String secondaryContactLogin, String secondaryContactName, String secondaryContactEmail, Boolean useHostHeaderAsSiteName)
at Microsoft.SharePoint.Administration.SPSiteCollection.Add(String siteUrl, String title, String description, UInt32 nLCID, String webTemplate, String ownerLogin, String ownerName, String ownerEmail, String secondaryContactLogin, String secondaryContactName, String secondaryContactEmail)
at Microsoft.SharePoint.Administration.SPSiteCollection.Add(String siteUrl, String title, String description, UInt32 nLCID, String webTemplate, String ownerLogin, String ownerName, String ownerEmail)
SharePoint\SharePointDataAccess.cs(25,0): at ImportOrgsUsers.SharePoint.SharePointDataAccess.CreateOrgSite(String path)
I looked all over the net and didn't find anything definitive. According to your stack trace the error is obviously being thrown by one of those annoying embedded COM objects. The best answer I can give you is that 0x80070057 is COM-speak for "General error" or "Invalid parameter" or something to that effect. My advice is to:
- put in a valid e-mail address instead of
String.Empty
- format
newSiteUrl
like they do here (eg. "sites/mynewsite")
If that doesn't work, then I wish you luck finding an answer :(
I know this question is ancient but I think your problem may have been that you were not able to actively connect to the domain. This is the behavior I run into when am working remotely using domain accounts but not not connected to the VPN. When attempting to create the site SharePoint needs to connect to the domain to get information about the site owner you're specifying.
精彩评论