From a0d9e59db2087e88f10b6a7c6821107da0fec2b9 Mon Sep 17 00:00:00 2001 From: robvde Date: Sun, 1 Jul 2012 08:24:49 +0400 Subject: [PATCH] Updated Hosted Sharepoing Provider (Foundation 2010): A) Powershell support added within the provider B) Now returns the actual deployed language packs C) The PeoplePicker points to the organization OU and shows only the users from the tentant organization. A requirement when used with Exchange 2010 SP2 Addressbook Policies D) Shared SSL root added to use wild card certificates as part of hosting plan. When enabled the host name is generated. E) Search fix: Provisioning of localhost file where the server component is active. This system expected to be the search server. Within the local hostfile the sites are listed with their local ip address so the search server can resolve the site and crawl through their data. This component needs to be compiled with .NET 2.0 together with Provers.Base, OS.Windows2003, OS.Windows2008, Server.Utils, and Server components. Out standing is to update the build and deployment package for a dedicated deployment packaged so this component is using .NET 2.0, all other should be using .NET 4.0. This will eliminate the configuration circus that was required to get the .NET 4.0 version of this component working previously. --- WebsitePanel/Database/QuotasSharepoint.sql | 1 + .../Packages/Quotas.cs | 3 +- .../HostedSharePointServerController.cs | 1274 +++++++++-------- .../HostedSolution/OrganizationUser.cs | 52 +- .../SharePoint/IHostedSharePointServer.cs | 154 +- .../SharePoint/SharePointSiteCollection.cs | 36 + .../HostedSharePointServer.cs | 527 +++---- .../HostedSharePointServer2010.cs | 245 ++++ .../HostedSharePointServerImpl.cs | 761 ++++++---- .../HostedSolutionLog.cs | 18 + .../HostedSharePointServerProxy.cs | 841 ++++++----- .../HostedSharePointServer.asmx.cs | 387 ++--- .../DomainsSelectDomainControl.ascx.cs | 3 +- .../UserControls/UserSelector.ascx | 2 +- .../UserControls/UserSelector.ascx.cs | 277 ++-- .../UserSelector.ascx.designer.cs | 3 +- .../HostedSharePointEditSiteCollection.ascx | 30 +- ...HostedSharePointEditSiteCollection.ascx.cs | 601 ++++---- ...rePointEditSiteCollection.ascx.designer.cs | 41 +- .../HostedSharePoint30_Settings.ascx.resx | 13 +- .../HostedSharePoint30_Settings.ascx | 17 +- .../HostedSharePoint30_Settings.ascx.cs | 93 +- ...stedSharePoint30_Settings.ascx.designer.cs | 30 +- .../UserControls/QuotaEditor.ascx.cs | 18 +- .../UserControls/QuotaEditor.ascx.designer.cs | 3 +- 25 files changed, 3174 insertions(+), 2256 deletions(-) create mode 100644 WebsitePanel/Database/QuotasSharepoint.sql diff --git a/WebsitePanel/Database/QuotasSharepoint.sql b/WebsitePanel/Database/QuotasSharepoint.sql new file mode 100644 index 00000000..d3b94426 --- /dev/null +++ b/WebsitePanel/Database/QuotasSharepoint.sql @@ -0,0 +1 @@ +INSERT INTO Quotas (QuotaID, GroupID, QuotaOrder, QuotaName,QuotaDescription, QuotaTypeID, ServiceQuota) VALUES (400, 20, 3, 'HostedSharePoint.UseSharedSSL' ,'Use shared SSL Root', 1, 0) \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Packages/Quotas.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Packages/Quotas.cs index b1362844..0f353415 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Packages/Quotas.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Packages/Quotas.cs @@ -136,7 +136,8 @@ order by rg.groupOrder public const string SHAREPOINT_SITES = "SharePoint.Sites"; // SharePoint Sites public const string HOSTED_SHAREPOINT_SITES = "HostedSharePoint.Sites"; // Hosted SharePoint Sites public const string HOSTED_SHAREPOINT_STORAGE_SIZE = "HostedSharePoint.MaxStorage"; // Hosted SharePoint storage size; - public const string DNS_EDITOR = "DNS.Editor"; // DNS Editor + public const string HOSTED_SHAREPOINT_USESHAREDSSL = "HostedSharePoint.UseSharedSSL"; // Hosted SharePoint Use Shared SSL Root + public const string DNS_EDITOR = "DNS.Editor"; // DNS Editor public const string DNS_ZONES = "DNS.Zones"; // DNS Editor public const string DNS_PRIMARY_ZONES = "DNS.PrimaryZones"; // DNS Editor public const string DNS_SECONDARY_ZONES = "DNS.SecondaryZones"; // DNS Editor diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/SharePoint/HostedSharePointServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/SharePoint/HostedSharePointServerController.cs index ea1011a2..8d149714 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/SharePoint/HostedSharePointServerController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/SharePoint/HostedSharePointServerController.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2012, Outercurve Foundation. +// Copyright (c) 2011, Outercurve Foundation. // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, @@ -40,26 +40,26 @@ using WebsitePanel.Providers.SharePoint; namespace WebsitePanel.EnterpriseServer.Code.SharePoint { - /// - /// Exposes handful API on hosted SharePoint site collections management. - /// - public class HostedSharePointServerController : IImportController, IBackupController - { - private const int FILE_BUFFER_LENGTH = 5000000; // ~5MB + /// + /// Exposes handful API on hosted SharePoint site collections management. + /// + public class HostedSharePointServerController : IImportController, IBackupController + { + private const int FILE_BUFFER_LENGTH = 5000000; // ~5MB - /// - /// Gets site collections in raw form. - /// - /// Package to which desired site collections belong. - /// Organization to which desired site collections belong. - /// Filter column name. - /// Filter value. - /// Sort column name. - /// Row index to start from. - /// Maximum number of rows to retrieve. - /// Site collections that match. - public static SharePointSiteCollectionListPaged GetSiteCollectionsPaged(int packageId, int organizationId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows) - { + /// + /// Gets site collections in raw form. + /// + /// Package to which desired site collections belong. + /// Organization to which desired site collections belong. + /// Filter column name. + /// Filter value. + /// Sort column name. + /// Row index to start from. + /// Maximum number of rows to retrieve. + /// Site collections that match. + public static SharePointSiteCollectionListPaged GetSiteCollectionsPaged(int packageId, int organizationId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows) + { if (IsDemoMode) { SharePointSiteCollectionListPaged demoResult = new SharePointSiteCollectionListPaged(); @@ -68,35 +68,35 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint return demoResult; } - SharePointSiteCollectionListPaged paged = new SharePointSiteCollectionListPaged(); - DataSet result = PackageController.GetRawPackageItemsPaged(packageId, typeof(SharePointSiteCollection), - true, filterColumn, filterValue, sortColumn, startRow, Int32.MaxValue); - List items = PackageController.CreateServiceItemsList(result, 1).ConvertAll(delegate(ServiceProviderItem item) { return (SharePointSiteCollection)item; }); + SharePointSiteCollectionListPaged paged = new SharePointSiteCollectionListPaged(); + DataSet result = PackageController.GetRawPackageItemsPaged(packageId, typeof(SharePointSiteCollection), + true, filterColumn, filterValue, sortColumn, startRow, Int32.MaxValue); + List items = PackageController.CreateServiceItemsList(result, 1).ConvertAll(delegate(ServiceProviderItem item) { return (SharePointSiteCollection)item; }); - if (organizationId > 0) - { - items = items.FindAll(delegate(SharePointSiteCollection siteCollection) { return siteCollection.OrganizationId == organizationId; }); - } - paged.TotalRowCount = items.Count; + if (organizationId > 0) + { + items = items.FindAll(delegate(SharePointSiteCollection siteCollection) { return siteCollection.OrganizationId == organizationId; }); + } + paged.TotalRowCount = items.Count; - if (items.Count > maximumRows) - { - items.RemoveRange(maximumRows, items.Count - maximumRows); - } + if (items.Count > maximumRows) + { + items.RemoveRange(maximumRows, items.Count - maximumRows); + } - paged.SiteCollections = items; + paged.SiteCollections = items; - return paged; - } + return paged; + } public static List GetSiteCollections(int organizationId) { Organization org = OrganizationController.GetOrganization(organizationId); - - List items = PackageController.GetPackageItemsByType(org.PackageId, typeof(SharePointSiteCollection), false); + + List items = PackageController.GetPackageItemsByType(org.PackageId, typeof(SharePointSiteCollection), false); items.ConvertAll(delegate(ServiceProviderItem item) { return (SharePointSiteCollection)item; }); List ret = new List(); - foreach(ServiceProviderItem item in items) + foreach (ServiceProviderItem item in items) { SharePointSiteCollection siteCollection = item as SharePointSiteCollection; if (siteCollection != null && siteCollection.OrganizationId == organizationId) @@ -104,54 +104,54 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint ret.Add(siteCollection); } } - - return ret; + + return ret; } - /// - /// Gets list of supported languages by this installation of SharePoint. - /// - /// List of supported languages - public static int[] GetSupportedLanguages(int packageId) - { + /// + /// Gets list of supported languages by this installation of SharePoint. + /// + /// List of supported languages + public static int[] GetSupportedLanguages(int packageId) + { if (IsDemoMode) { - return new int[] {1033}; + return new int[] { 1033 }; } - // Log operation. - TaskManager.StartTask("HOSTEDSHAREPOINT", "GET_LANGUAGES"); + // Log operation. + TaskManager.StartTask("HOSTEDSHAREPOINT", "GET_LANGUAGES"); - int serviceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.HostedSharePoint); - if (serviceId == 0) - { - return new int[]{}; - } + int serviceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.HostedSharePoint); + if (serviceId == 0) + { + return new int[] { }; + } - try - { - // Create site collection on server. - HostedSharePointServer hostedSharePointServer = GetHostedSharePointServer(serviceId); - return hostedSharePointServer.GetSupportedLanguages(); - } - catch (Exception ex) - { - throw TaskManager.WriteError(ex); - } - finally - { - TaskManager.CompleteTask(); - } - } + try + { + // Create site collection on server. + HostedSharePointServer hostedSharePointServer = GetHostedSharePointServer(serviceId); + return hostedSharePointServer.GetSupportedLanguages(); + } + catch (Exception ex) + { + throw TaskManager.WriteError(ex); + } + finally + { + TaskManager.CompleteTask(); + } + } - /// - /// Gets list of SharePoint site collections that belong to the package. - /// - /// Package that owns site collections. - /// A value which shows whether nested spaces must be searched as well. - /// List of found site collections. - public static List GetSiteCollections(int packageId, bool recursive) - { + /// + /// Gets list of SharePoint site collections that belong to the package. + /// + /// Package that owns site collections. + /// A value which shows whether nested spaces must be searched as well. + /// List of found site collections. + public static List GetSiteCollections(int packageId, bool recursive) + { if (IsDemoMode) { List demoResult = new List(); @@ -183,592 +183,626 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint } - List items = PackageController.GetPackageItemsByType(packageId, typeof(SharePointSiteCollection), recursive); - return items.ConvertAll(delegate(ServiceProviderItem item) { return (SharePointSiteCollection)item; }); - } + List items = PackageController.GetPackageItemsByType(packageId, typeof(SharePointSiteCollection), recursive); + return items.ConvertAll(delegate(ServiceProviderItem item) { return (SharePointSiteCollection)item; }); + } - /// - /// Gets SharePoint site collection with given id. - /// - /// Site collection id within metabase. - /// Site collection or null in case no such item exist. - public static SharePointSiteCollection GetSiteCollection(int itemId) - { + /// + /// Gets SharePoint site collection with given id. + /// + /// Site collection id within metabase. + /// Site collection or null in case no such item exist. + public static SharePointSiteCollection GetSiteCollection(int itemId) + { if (IsDemoMode) { - return GetSiteCollections(1, false)[itemId-1]; + return GetSiteCollections(1, false)[itemId - 1]; } - SharePointSiteCollection item = PackageController.GetPackageItem(itemId) as SharePointSiteCollection; - return item; - } + SharePointSiteCollection item = PackageController.GetPackageItem(itemId) as SharePointSiteCollection; + return item; + } - /// - /// Adds SharePoint site collection. - /// - /// Site collection description. - /// Created site collection id within metabase. - public static int AddSiteCollection(SharePointSiteCollection item) - { - string domainName = item.Name; - // Check account. - int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive); - if (accountCheck < 0) - { - return accountCheck; - } + /// + /// Adds SharePoint site collection. + /// + /// Site collection description. + /// Created site collection id within metabase. + public static int AddSiteCollection(SharePointSiteCollection item) + { - // Check package. - int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive); - if (packageCheck < 0) - { - return packageCheck; - } + // Check account. + int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive); + if (accountCheck < 0) + { + return accountCheck; + } - // Check quota. - OrganizationStatistics orgStats = OrganizationController.GetOrganizationStatistics(item.OrganizationId); - //QuotaValueInfo quota = PackageController.GetPackageQuota(item.PackageId, Quotas.HOSTED_SHAREPOINT_SITES); + // Check package. + int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive); + if (packageCheck < 0) + { + return packageCheck; + } - if (orgStats.AllocatedSharePointSiteCollections > -1 - && orgStats.CreatedSharePointSiteCollections >= orgStats.AllocatedSharePointSiteCollections) - { - return BusinessErrorCodes.ERROR_SHAREPOINT_RESOURCE_QUOTA_LIMIT; - } + // Check quota. + OrganizationStatistics orgStats = OrganizationController.GetOrganizationStatistics(item.OrganizationId); + //QuotaValueInfo quota = PackageController.GetPackageQuota(item.PackageId, Quotas.HOSTED_SHAREPOINT_SITES); - // Check if stats resource is available - int serviceId = PackageController.GetPackageServiceId(item.PackageId, ResourceGroups.HostedSharePoint); - if (serviceId == 0) - { - return BusinessErrorCodes.ERROR_SHAREPOINT_RESOURCE_UNAVAILABLE; - } - StringDictionary hostedSharePointSettings = ServerController.GetServiceSettings(serviceId); - Uri rootWebApplicationUri = new Uri(hostedSharePointSettings["RootWebApplicationUri"]); - item.Name = String.Format("{0}://{1}", rootWebApplicationUri.Scheme, item.Name); - if (rootWebApplicationUri.Port > 0 && rootWebApplicationUri.Port != 80 && rootWebApplicationUri.Port != 443) - { - item.PhysicalAddress = String.Format("{0}:{1}", item.Name, rootWebApplicationUri.Port); - } - else - { - item.PhysicalAddress = item.Name; - } + if (orgStats.AllocatedSharePointSiteCollections > -1 + && orgStats.CreatedSharePointSiteCollections >= orgStats.AllocatedSharePointSiteCollections) + { + return BusinessErrorCodes.ERROR_SHAREPOINT_RESOURCE_QUOTA_LIMIT; + } - Organization org = OrganizationController.GetOrganization(item.OrganizationId); + // Check if stats resource is available + int serviceId = PackageController.GetPackageServiceId(item.PackageId, ResourceGroups.HostedSharePoint); + if (serviceId == 0) + { + return BusinessErrorCodes.ERROR_SHAREPOINT_RESOURCE_UNAVAILABLE; + } + + StringDictionary hostedSharePointSettings = ServerController.GetServiceSettings(serviceId); + QuotaValueInfo quota = PackageController.GetPackageQuota(item.PackageId, Quotas.HOSTED_SHAREPOINT_USESHAREDSSL); + Uri rootWebApplicationUri = new Uri(hostedSharePointSettings["RootWebApplicationUri"]); + Organization org = OrganizationController.GetOrganization(item.OrganizationId); + string siteName = item.Name; + + if (quota.QuotaAllocatedValue == 1) + { + string sslRoot = hostedSharePointSettings["SharedSSLRoot"]; + + + string defaultDomain = org.DefaultDomain; + string hostNameBase = string.Empty; + + string[] tmp = defaultDomain.Split('.'); + if (tmp.Length == 2) + { + hostNameBase = tmp[0]; + } + else + { + if (tmp.Length > 2) + { + hostNameBase = tmp[0] + tmp[1]; + } + } + + int counter = 0; + item.Name = String.Format("{0}://{1}", rootWebApplicationUri.Scheme, hostNameBase + "-" + counter.ToString() + "." + sslRoot); + siteName = String.Format("{0}", hostNameBase + "-" + counter.ToString() + "." + sslRoot); + + while (DataProvider.CheckServiceItemExists(serviceId, item.Name, "WebsitePanel.Providers.SharePoint.SharePointSiteCollection, WebsitePanel.Providers.Base")) + { + counter++; + item.Name = String.Format("{0}://{1}", rootWebApplicationUri.Scheme, hostNameBase + "-" + counter.ToString() + "." + sslRoot); + siteName = String.Format("{0}", hostNameBase + "-" + counter.ToString() + "." + sslRoot); + } + } + else + item.Name = String.Format("{0}://{1}", rootWebApplicationUri.Scheme, item.Name); + + if (rootWebApplicationUri.Port > 0 && rootWebApplicationUri.Port != 80 && rootWebApplicationUri.Port != 443) + { + item.PhysicalAddress = String.Format("{0}:{1}", item.Name, rootWebApplicationUri.Port); + } + else + { + item.PhysicalAddress = item.Name; + } + + if (Utils.ParseBool(hostedSharePointSettings["LocalHostFile"], false)) + { + item.RootWebApplicationInteralIpAddress = hostedSharePointSettings["RootWebApplicationInteralIpAddress"]; + item.RootWebApplicationFQDN = item.Name.Replace(rootWebApplicationUri.Scheme + "://", ""); + } item.MaxSiteStorage = RecalculateMaxSize(org.MaxSharePointStorage, (int)item.MaxSiteStorage); - item.WarningStorage = item.MaxSiteStorage == -1 ? -1 : Math.Min((int)item.WarningStorage, item.MaxSiteStorage) ; - - + item.WarningStorage = item.MaxSiteStorage == -1 ? -1 : Math.Min((int)item.WarningStorage, item.MaxSiteStorage); + + // Check package item with given name already exists. - if (PackageController.GetPackageItemByName(item.PackageId, item.Name, typeof(SharePointSiteCollection)) != null) - { - return BusinessErrorCodes.ERROR_SHAREPOINT_PACKAGE_ITEM_EXISTS; - } - - // Log operation. - TaskManager.StartTask("HOSTEDSHAREPOINT", "ADD_SITE_COLLECTION", item.Name); + if (PackageController.GetPackageItemByName(item.PackageId, item.Name, typeof(SharePointSiteCollection)) != null) + { + return BusinessErrorCodes.ERROR_SHAREPOINT_PACKAGE_ITEM_EXISTS; + } + + // Log operation. + TaskManager.StartTask("HOSTEDSHAREPOINT", "ADD_SITE_COLLECTION", item.Name); + + try + { + // Create site collection on server. + HostedSharePointServer hostedSharePointServer = GetHostedSharePointServer(serviceId); - try - { - // Create site collection on server. - HostedSharePointServer hostedSharePointServer = GetHostedSharePointServer(serviceId); - hostedSharePointServer.CreateSiteCollection(item); - // Make record in metabase. - item.ServiceId = serviceId; - int itemId = PackageController.AddPackageItem(item); - int dnsServiceId = PackageController.GetPackageServiceId(item.PackageId, ResourceGroups.Dns); - if (dnsServiceId > 0) - { - DomainInfo domain = ServerController.GetDomain(domainName); - if (domain != null) - { - string website = domain.WebSiteName; - - if (!String.IsNullOrEmpty(domain.WebSiteName)) + // Make record in metabase. + item.ServiceId = serviceId; + int itemId = PackageController.AddPackageItem(item); + + hostedSharePointServer.SetPeoplePickerOu(item.Name, org.DistinguishedName); + + int dnsServiceId = PackageController.GetPackageServiceId(item.PackageId, ResourceGroups.Dns); + if (dnsServiceId > 0) + { + string[] tmpStr = siteName.Split('.'); + string hostName = tmpStr[0]; + string domainName = siteName.Substring(hostName.Length + 1, siteName.Length - (hostName.Length + 1)); + + DomainInfo domain = ServerController.GetDomain(domainName); + if (domain != null) + { + string website = siteName; + + DnsRecord[] records = ServerController.GetDnsZoneRecords(domain.DomainId); + foreach (DnsRecord record in records) { - DnsRecord[] records = ServerController.GetDnsZoneRecords(domain.DomainId); - foreach (DnsRecord record in records) + if (record.RecordType.Equals(DnsRecordType.A) && (record.RecordName == hostName)) { - if (record.RecordType.Equals(DnsRecordType.A) && String.IsNullOrEmpty(record.RecordName)) - { - ServerController.DeleteDnsZoneRecord(domain.DomainId, String.Empty, DnsRecordType.A, record.RecordData); - break; - } - } - - } - ServerController.AddDnsZoneRecord(domain.DomainId, String.Empty, DnsRecordType.A, hostedSharePointSettings["RootWebApplicationIpAddress"], 0); - } - } - - TaskManager.ItemId = itemId; - return itemId; - } - catch(Exception ex) - { - throw TaskManager.WriteError(ex); - } - finally - { - TaskManager.CompleteTask(); - } - } - - /// - /// Deletes SharePoint site collection with given id. - /// - /// Site collection id within metabase. - /// ? - public static int DeleteSiteCollection(int itemId) - { - // Check account. - int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive); - if (accountCheck < 0) - { - return accountCheck; - } - - // Load original meta item - SharePointSiteCollection origItem = (SharePointSiteCollection) PackageController.GetPackageItem(itemId); - if (origItem == null) - { - return BusinessErrorCodes.ERROR_SHAREPOINT_PACKAGE_ITEM_NOT_FOUND; - } - - // Get service settings. - StringDictionary hostedSharePointSettings = ServerController.GetServiceSettings(origItem.ServiceId); - Uri rootWebApplicationUri = new Uri(hostedSharePointSettings["RootWebApplicationUri"]); - string domainName = origItem.Name.Replace(String.Format("{0}://", rootWebApplicationUri.Scheme), String.Empty); - - // Log operation. - TaskManager.StartTask("HOSTEDSHAREPOINT", "DELETE_SITE", origItem.Name); - TaskManager.ItemId = itemId; - - try - { - // Delete site collection on server. - HostedSharePointServer hostedSharePointServer = GetHostedSharePointServer(origItem.ServiceId); - hostedSharePointServer.DeleteSiteCollection(origItem.Url); - // Delete record in metabase. - PackageController.DeletePackageItem(origItem.Id); - - int dnsServiceId = PackageController.GetPackageServiceId(origItem.PackageId, ResourceGroups.Dns); - if (dnsServiceId > 0) - { - DomainInfo domain = ServerController.GetDomain(domainName); - if (domain != null) - { - ServerController.DeleteDnsZoneRecord(domain.DomainId, String.Empty, DnsRecordType.A, hostedSharePointSettings["RootWebApplicationIpAddress"]); - ServerController.DeleteDnsZoneRecord(domain.DomainId, "www", DnsRecordType.A, hostedSharePointSettings["RootWebApplicationIpAddress"]); - - if (!String.IsNullOrEmpty(domain.WebSiteName)) - { - DnsRecord[] records = ServerController.GetDnsZoneRecords(domain.DomainId); - foreach (DnsRecord record in records) - { - if (record.RecordType.Equals(DnsRecordType.A) && record.RecordName.Equals("www", StringComparison.CurrentCultureIgnoreCase)) - { - ServerController.AddDnsZoneRecord(domain.DomainId, String.Empty, DnsRecordType.A, - record.RecordData, 0); - break; - } + ServerController.DeleteDnsZoneRecord(domain.DomainId, hostName, DnsRecordType.A, record.RecordData); + break; } } - } - } + ServerController.AddDnsZoneRecord(domain.DomainId, hostName, DnsRecordType.A, hostedSharePointSettings["RootWebApplicationIpAddress"], 0); + } + } + TaskManager.ItemId = itemId; + return itemId; + } + catch (Exception ex) + { + throw TaskManager.WriteError(ex); + } + finally + { + TaskManager.CompleteTask(); + } + } - return 0; - } - catch (Exception ex) - { - throw TaskManager.WriteError(ex); - } - finally - { - TaskManager.CompleteTask(); - } - } + /// + /// Deletes SharePoint site collection with given id. + /// + /// Site collection id within metabase. + /// ? + public static int DeleteSiteCollection(int itemId) + { + // Check account. + int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive); + if (accountCheck < 0) + { + return accountCheck; + } - /// - /// Deletes SharePoint site collections which belong to organization. - /// - /// Site collection id within metabase. - public static void DeleteSiteCollections(int organizationId) - { - Organization org = OrganizationController.GetOrganization(organizationId); - SharePointSiteCollectionListPaged existentSiteCollections = GetSiteCollectionsPaged(org.PackageId, org.Id, String.Empty, String.Empty, String.Empty, 0, Int32.MaxValue); - foreach (SharePointSiteCollection existentSiteCollection in existentSiteCollections.SiteCollections) - { - DeleteSiteCollection(existentSiteCollection.Id); - } - } + // Load original meta item + SharePointSiteCollection origItem = (SharePointSiteCollection)PackageController.GetPackageItem(itemId); + if (origItem == null) + { + return BusinessErrorCodes.ERROR_SHAREPOINT_PACKAGE_ITEM_NOT_FOUND; + } - /// - /// Backups SharePoint site collection. - /// - /// Site collection id within metabase. - /// Backed up site collection file name. - /// A value which shows whether back up must be archived. - /// A value which shows whether created back up must be downloaded. - /// Local folder to store downloaded backup. - /// Created backup file name. - public static string BackupSiteCollection(int itemId, string fileName, bool zipBackup, bool download, string folderName) - { - // Check account. - int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive); - if (accountCheck < 0) - { - return null; - } + // Get service settings. + StringDictionary hostedSharePointSettings = ServerController.GetServiceSettings(origItem.ServiceId); + Uri rootWebApplicationUri = new Uri(hostedSharePointSettings["RootWebApplicationUri"]); + string siteName = origItem.Name.Replace(String.Format("{0}://", rootWebApplicationUri.Scheme), String.Empty); - // Load original meta item - SharePointSiteCollection origItem = (SharePointSiteCollection)PackageController.GetPackageItem(itemId); - if (origItem == null) - { - return null; - } + // Log operation. + TaskManager.StartTask("HOSTEDSHAREPOINT", "DELETE_SITE", origItem.Name); + TaskManager.ItemId = itemId; - // Log operation. - TaskManager.StartTask("HOSTEDSHAREPOINT", "BACKUP_SITE_COLLECTION", origItem.Name); - TaskManager.ItemId = itemId; + try + { + // Delete site collection on server. + HostedSharePointServer hostedSharePointServer = GetHostedSharePointServer(origItem.ServiceId); + hostedSharePointServer.DeleteSiteCollection(origItem); + // Delete record in metabase. + PackageController.DeletePackageItem(origItem.Id); - try - { - // Create site collection on server. - HostedSharePointServer hostedSharePointServer = GetHostedSharePointServer(origItem.ServiceId); - string backFile = hostedSharePointServer.BackupSiteCollection(origItem.Name, fileName, zipBackup); + int dnsServiceId = PackageController.GetPackageServiceId(origItem.PackageId, ResourceGroups.Dns); + if (dnsServiceId > 0) + { + string[] tmpStr = siteName.Split('.'); + string hostName = tmpStr[0]; + string domainName = siteName.Substring(hostName.Length + 1, siteName.Length - (hostName.Length + 1)); - if (!download) - { - // Copy backup files to space folder. - string relFolderName = FilesController.CorrectRelativePath(folderName); - if (!relFolderName.EndsWith("\\")) - { - relFolderName = relFolderName + "\\"; - } + DomainInfo domain = ServerController.GetDomain(domainName); + if (domain != null) + { + ServerController.DeleteDnsZoneRecord(domain.DomainId, hostName, DnsRecordType.A, hostedSharePointSettings["RootWebApplicationIpAddress"]); + } + } - // Create backup folder if not exists - if (!FilesController.DirectoryExists(origItem.PackageId, relFolderName)) - { - FilesController.CreateFolder(origItem.PackageId, relFolderName); - } + return 0; + } + catch (Exception ex) + { + throw TaskManager.WriteError(ex); + } + finally + { + TaskManager.CompleteTask(); + } + } - string packageFile = relFolderName + Path.GetFileName(backFile); + /// + /// Deletes SharePoint site collections which belong to organization. + /// + /// Site collection id within metabase. + public static void DeleteSiteCollections(int organizationId) + { + Organization org = OrganizationController.GetOrganization(organizationId); + SharePointSiteCollectionListPaged existentSiteCollections = GetSiteCollectionsPaged(org.PackageId, org.Id, String.Empty, String.Empty, String.Empty, 0, Int32.MaxValue); + foreach (SharePointSiteCollection existentSiteCollection in existentSiteCollections.SiteCollections) + { + DeleteSiteCollection(existentSiteCollection.Id); + } + } - // Delete destination file if exists - if (FilesController.FileExists(origItem.PackageId, packageFile)) - { - FilesController.DeleteFiles(origItem.PackageId, new string[] { packageFile }); - } + /// + /// Backups SharePoint site collection. + /// + /// Site collection id within metabase. + /// Backed up site collection file name. + /// A value which shows whether back up must be archived. + /// A value which shows whether created back up must be downloaded. + /// Local folder to store downloaded backup. + /// Created backup file name. + public static string BackupSiteCollection(int itemId, string fileName, bool zipBackup, bool download, string folderName) + { + // Check account. + int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive); + if (accountCheck < 0) + { + return null; + } - byte[] buffer = null; + // Load original meta item + SharePointSiteCollection origItem = (SharePointSiteCollection)PackageController.GetPackageItem(itemId); + if (origItem == null) + { + return null; + } - int offset = 0; - do - { - // Read remote content. - buffer = hostedSharePointServer.GetTempFileBinaryChunk(backFile, offset, FILE_BUFFER_LENGTH); + // Log operation. + TaskManager.StartTask("HOSTEDSHAREPOINT", "BACKUP_SITE_COLLECTION", origItem.Name); + TaskManager.ItemId = itemId; - // Write remote content. - FilesController.AppendFileBinaryChunk(origItem.PackageId, packageFile, buffer); + try + { + // Create site collection on server. + HostedSharePointServer hostedSharePointServer = GetHostedSharePointServer(origItem.ServiceId); + string backFile = hostedSharePointServer.BackupSiteCollection(origItem.Name, fileName, zipBackup); - offset += FILE_BUFFER_LENGTH; - } - while (buffer.Length == FILE_BUFFER_LENGTH); - } + if (!download) + { + // Copy backup files to space folder. + string relFolderName = FilesController.CorrectRelativePath(folderName); + if (!relFolderName.EndsWith("\\")) + { + relFolderName = relFolderName + "\\"; + } - return backFile; - } - catch (Exception ex) - { - throw TaskManager.WriteError(ex); - } - finally - { - TaskManager.CompleteTask(); - } - } + // Create backup folder if not exists + if (!FilesController.DirectoryExists(origItem.PackageId, relFolderName)) + { + FilesController.CreateFolder(origItem.PackageId, relFolderName); + } - /// - /// Restores SharePoint site collection. - /// - /// Site collection id within metabase. - /// - /// - /// - public static int RestoreSiteCollection(int itemId, string uploadedFile, string packageFile) - { - // Check account. - int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive); - if (accountCheck < 0) - { - return accountCheck; - } + string packageFile = relFolderName + Path.GetFileName(backFile); - // Load original meta item. - SharePointSiteCollection origItem = (SharePointSiteCollection)PackageController.GetPackageItem(itemId); - if (origItem == null) - { - return BusinessErrorCodes.ERROR_SHAREPOINT_PACKAGE_ITEM_NOT_FOUND; - } + // Delete destination file if exists + if (FilesController.FileExists(origItem.PackageId, packageFile)) + { + FilesController.DeleteFiles(origItem.PackageId, new string[] { packageFile }); + } - // Check package. - int packageCheck = SecurityContext.CheckPackage(origItem.PackageId, DemandPackage.IsActive); - if (packageCheck < 0) - { - return packageCheck; - } + byte[] buffer = null; - // Log operation. - TaskManager.StartTask("HOSTEDSHAREPOINT", "BACKUP_SITE_COLLECTION", origItem.Name); - TaskManager.ItemId = itemId; + int offset = 0; + do + { + // Read remote content. + buffer = hostedSharePointServer.GetTempFileBinaryChunk(backFile, offset, FILE_BUFFER_LENGTH); - try - { - // Create site collection on server. - HostedSharePointServer hostedSharePointServer = GetHostedSharePointServer(origItem.ServiceId); + // Write remote content. + FilesController.AppendFileBinaryChunk(origItem.PackageId, packageFile, buffer); - string backupFile = null; - if (!String.IsNullOrEmpty(packageFile)) - { - // Copy package files to the remote SharePoint Server. - string path = null; - byte[] buffer = null; + offset += FILE_BUFFER_LENGTH; + } + while (buffer.Length == FILE_BUFFER_LENGTH); + } - int offset = 0; - do - { - // Read package file. - buffer = FilesController.GetFileBinaryChunk(origItem.PackageId, packageFile, offset, FILE_BUFFER_LENGTH); + return backFile; + } + catch (Exception ex) + { + throw TaskManager.WriteError(ex); + } + finally + { + TaskManager.CompleteTask(); + } + } - // Write remote backup file - string tempPath = hostedSharePointServer.AppendTempFileBinaryChunk(Path.GetFileName(packageFile), path, buffer); - if (path == null) - { - path = tempPath; - backupFile = path; - } + /// + /// Restores SharePoint site collection. + /// + /// Site collection id within metabase. + /// + /// + /// + public static int RestoreSiteCollection(int itemId, string uploadedFile, string packageFile) + { + // Check account. + int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive); + if (accountCheck < 0) + { + return accountCheck; + } - offset += FILE_BUFFER_LENGTH; - } - while (buffer.Length == FILE_BUFFER_LENGTH); - } - else if (!String.IsNullOrEmpty(uploadedFile)) - { - // Upladed files. - backupFile = uploadedFile; - } + // Load original meta item. + SharePointSiteCollection origItem = (SharePointSiteCollection)PackageController.GetPackageItem(itemId); + if (origItem == null) + { + return BusinessErrorCodes.ERROR_SHAREPOINT_PACKAGE_ITEM_NOT_FOUND; + } - // Restore. - if (!String.IsNullOrEmpty(backupFile)) - { - hostedSharePointServer.RestoreSiteCollection(origItem, backupFile); - } + // Check package. + int packageCheck = SecurityContext.CheckPackage(origItem.PackageId, DemandPackage.IsActive); + if (packageCheck < 0) + { + return packageCheck; + } - return 0; - } - catch (Exception ex) - { - throw TaskManager.WriteError(ex); - } - finally - { - TaskManager.CompleteTask(); - } - } + // Log operation. + TaskManager.StartTask("HOSTEDSHAREPOINT", "BACKUP_SITE_COLLECTION", origItem.Name); + TaskManager.ItemId = itemId; - /// - /// Gets binary data chunk of specified size from specified offset. - /// - /// Item id to obtain realted service id. - /// Path to file to get bunary data chunk from. - /// Offset from which to start data reading. - /// Binary data chunk length. - /// Binary data chunk read from file. - public static byte[] GetBackupBinaryChunk(int itemId, string path, int offset, int length) - { - // Load original meta item. - SharePointSiteCollection item = (SharePointSiteCollection)PackageController.GetPackageItem(itemId); - if (item == null) - { - return null; - } + try + { + // Create site collection on server. + HostedSharePointServer hostedSharePointServer = GetHostedSharePointServer(origItem.ServiceId); - HostedSharePointServer hostedSharePointServer = GetHostedSharePointServer(item.ServiceId); - return hostedSharePointServer.GetTempFileBinaryChunk(path, offset, length); - } + string backupFile = null; + if (!String.IsNullOrEmpty(packageFile)) + { + // Copy package files to the remote SharePoint Server. + string path = null; + byte[] buffer = null; - /// - /// Appends supplied binary data chunk to file. - /// - /// Item id to obtain realted service id. - /// Non existent file name to append to. - /// Full path to existent file to append to. - /// Binary data chunk to append to. - /// Path to file that was appended with chunk. - public static string AppendBackupBinaryChunk(int itemId, string fileName, string path, byte[] chunk) - { - // Load original meta item. - SharePointSiteCollection item = (SharePointSiteCollection)PackageController.GetPackageItem(itemId); - if (item == null) - { - return null; - } + int offset = 0; + do + { + // Read package file. + buffer = FilesController.GetFileBinaryChunk(origItem.PackageId, packageFile, offset, FILE_BUFFER_LENGTH); - HostedSharePointServer hostedSharePointServer = GetHostedSharePointServer(item.ServiceId); - return hostedSharePointServer.AppendTempFileBinaryChunk(fileName, path, chunk); - } + // Write remote backup file + string tempPath = hostedSharePointServer.AppendTempFileBinaryChunk(Path.GetFileName(packageFile), path, buffer); + if (path == null) + { + path = tempPath; + backupFile = path; + } + + offset += FILE_BUFFER_LENGTH; + } + while (buffer.Length == FILE_BUFFER_LENGTH); + } + else if (!String.IsNullOrEmpty(uploadedFile)) + { + // Upladed files. + backupFile = uploadedFile; + } + + // Restore. + if (!String.IsNullOrEmpty(backupFile)) + { + hostedSharePointServer.RestoreSiteCollection(origItem, backupFile); + } + + return 0; + } + catch (Exception ex) + { + throw TaskManager.WriteError(ex); + } + finally + { + TaskManager.CompleteTask(); + } + } + + /// + /// Gets binary data chunk of specified size from specified offset. + /// + /// Item id to obtain realted service id. + /// Path to file to get bunary data chunk from. + /// Offset from which to start data reading. + /// Binary data chunk length. + /// Binary data chunk read from file. + public static byte[] GetBackupBinaryChunk(int itemId, string path, int offset, int length) + { + // Load original meta item. + SharePointSiteCollection item = (SharePointSiteCollection)PackageController.GetPackageItem(itemId); + if (item == null) + { + return null; + } + + HostedSharePointServer hostedSharePointServer = GetHostedSharePointServer(item.ServiceId); + return hostedSharePointServer.GetTempFileBinaryChunk(path, offset, length); + } + + /// + /// Appends supplied binary data chunk to file. + /// + /// Item id to obtain realted service id. + /// Non existent file name to append to. + /// Full path to existent file to append to. + /// Binary data chunk to append to. + /// Path to file that was appended with chunk. + public static string AppendBackupBinaryChunk(int itemId, string fileName, string path, byte[] chunk) + { + // Load original meta item. + SharePointSiteCollection item = (SharePointSiteCollection)PackageController.GetPackageItem(itemId); + if (item == null) + { + return null; + } + + HostedSharePointServer hostedSharePointServer = GetHostedSharePointServer(item.ServiceId); + return hostedSharePointServer.AppendTempFileBinaryChunk(fileName, path, chunk); + } + + /// + /// Initializes a new hosted SharePoint server proxy. + /// + /// Hosted SharePoint service id. + /// Hosted SharePoint server proxy. + private static HostedSharePointServer GetHostedSharePointServer(int serviceId) + { - /// - /// Initializes a new hosted SharePoint server proxy. - /// - /// Hosted SharePoint service id. - /// Hosted SharePoint server proxy. - private static HostedSharePointServer GetHostedSharePointServer(int serviceId) - { - HostedSharePointServer sps = new HostedSharePointServer(); - ServiceProviderProxy.Init(sps, serviceId); - return sps; - } + ServiceProviderProxy.Init(sps, serviceId); + return sps; + } - /// - /// Gets list of importable items. - /// - /// Package that owns importable items. - /// Item type id. - /// Item type. - /// Item resource group. - /// List of importable item names. - public List GetImportableItems(int packageId, int itemTypeId, Type itemType, ResourceGroupInfo group) - { - List items = new List(); + /// + /// Gets list of importable items. + /// + /// Package that owns importable items. + /// Item type id. + /// Item type. + /// Item resource group. + /// List of importable item names. + public List GetImportableItems(int packageId, int itemTypeId, Type itemType, ResourceGroupInfo group) + { + List items = new List(); - // Get service id - int serviceId = PackageController.GetPackageServiceId(packageId, group.GroupName); - if (serviceId == 0) - { - return items; - } + // Get service id + int serviceId = PackageController.GetPackageServiceId(packageId, group.GroupName); + if (serviceId == 0) + { + return items; + } - HostedSharePointServer hostedSharePointServer = GetHostedSharePointServer(serviceId); - if (itemType == typeof(SharePointSiteCollection)) - { - foreach (SharePointSiteCollection siteCollection in hostedSharePointServer.GetSiteCollections()) - { - items.Add(siteCollection.Url); - } - } + HostedSharePointServer hostedSharePointServer = GetHostedSharePointServer(serviceId); + if (itemType == typeof(SharePointSiteCollection)) + { + foreach (SharePointSiteCollection siteCollection in hostedSharePointServer.GetSiteCollections()) + { + items.Add(siteCollection.Url); + } + } - return items; - } + return items; + } - /// - /// Imports selected item into metabase. - /// - /// Package to which items must be imported. - /// Item type id. - /// Item type. - /// Item resource group. - /// Item name to import. - public void ImportItem(int packageId, int itemTypeId, Type itemType, ResourceGroupInfo group, string itemName) - { - // Get service id - int serviceId = PackageController.GetPackageServiceId(packageId, group.GroupName); - if (serviceId == 0) - { - return; - } + /// + /// Imports selected item into metabase. + /// + /// Package to which items must be imported. + /// Item type id. + /// Item type. + /// Item resource group. + /// Item name to import. + public void ImportItem(int packageId, int itemTypeId, Type itemType, ResourceGroupInfo group, string itemName) + { + // Get service id + int serviceId = PackageController.GetPackageServiceId(packageId, group.GroupName); + if (serviceId == 0) + { + return; + } - HostedSharePointServer hostedSharePointServer = GetHostedSharePointServer(serviceId); - if (itemType == typeof(SharePointSiteCollection)) - { - SharePointSiteCollection siteCollection = hostedSharePointServer.GetSiteCollection(itemName); - PackageController.AddPackageItem(siteCollection); - } - } + HostedSharePointServer hostedSharePointServer = GetHostedSharePointServer(serviceId); + if (itemType == typeof(SharePointSiteCollection)) + { + SharePointSiteCollection siteCollection = hostedSharePointServer.GetSiteCollection(itemName); + PackageController.AddPackageItem(siteCollection); + } + } - /// - /// Backups service item by serializing it into supplied writer. - /// - /// Temporary directory path. - /// Xml wirter used to store backuped service provider items. - /// Service provider item to be backed up.. - /// Service provider resource group. - /// Resulting code. - public int BackupItem(string tempFolder, XmlWriter writer, ServiceProviderItem item, ResourceGroupInfo group) - { - SharePointSiteCollection siteCollection = item as SharePointSiteCollection; - if (siteCollection != null) - { - HostedSharePointServer hostedSharePointServer = GetHostedSharePointServer(siteCollection.ServiceId); - SharePointSiteCollection loadedSiteCollection = hostedSharePointServer.GetSiteCollection(siteCollection.Url); - // Update item - siteCollection.Url = loadedSiteCollection.Url; - siteCollection.OwnerLogin = loadedSiteCollection.OwnerLogin; - siteCollection.OwnerName = loadedSiteCollection.OwnerName; - siteCollection.OwnerEmail = loadedSiteCollection.OwnerEmail; - siteCollection.LocaleId = loadedSiteCollection.LocaleId; - siteCollection.Title = loadedSiteCollection.Title; - siteCollection.Description = loadedSiteCollection.Description; - // Serialize it. - XmlSerializer serializer = new XmlSerializer(typeof(SharePointSiteCollection)); - serializer.Serialize(writer, siteCollection); + /// + /// Backups service item by serializing it into supplied writer. + /// + /// Temporary directory path. + /// Xml wirter used to store backuped service provider items. + /// Service provider item to be backed up.. + /// Service provider resource group. + /// Resulting code. + public int BackupItem(string tempFolder, XmlWriter writer, ServiceProviderItem item, ResourceGroupInfo group) + { + SharePointSiteCollection siteCollection = item as SharePointSiteCollection; + if (siteCollection != null) + { + HostedSharePointServer hostedSharePointServer = GetHostedSharePointServer(siteCollection.ServiceId); + SharePointSiteCollection loadedSiteCollection = hostedSharePointServer.GetSiteCollection(siteCollection.Url); + // Update item + siteCollection.Url = loadedSiteCollection.Url; + siteCollection.OwnerLogin = loadedSiteCollection.OwnerLogin; + siteCollection.OwnerName = loadedSiteCollection.OwnerName; + siteCollection.OwnerEmail = loadedSiteCollection.OwnerEmail; + siteCollection.LocaleId = loadedSiteCollection.LocaleId; + siteCollection.Title = loadedSiteCollection.Title; + siteCollection.Description = loadedSiteCollection.Description; + // Serialize it. + XmlSerializer serializer = new XmlSerializer(typeof(SharePointSiteCollection)); + serializer.Serialize(writer, siteCollection); - } - return 0; - } + } + return 0; + } - /// - /// Restore backed up previously service provider item. - /// - /// Temporary directory path. - /// Serialized service provider item. - /// Service provider item id. - /// Service provider item type. - /// Service provider item name. - /// Service provider item package. - /// Service provider item service id. - /// Service provider item resource group. - /// Resulting code. - public int RestoreItem(string tempFolder, XmlNode itemNode, int itemId, Type itemType, string itemName, int packageId, int serviceId, ResourceGroupInfo group) - { - if (itemType == typeof(SharePointSiteCollection)) - { - HostedSharePointServer hostedSharePointServer = GetHostedSharePointServer(serviceId); - // Deserialize item. - XmlSerializer serializer = new XmlSerializer(typeof(SharePointSiteCollection)); - SharePointSiteCollection siteCollection = (SharePointSiteCollection)serializer.Deserialize(new XmlNodeReader(itemNode.SelectSingleNode("SharePointSiteCollection"))); - siteCollection.PackageId = packageId; - siteCollection.ServiceId = serviceId; + /// + /// Restore backed up previously service provider item. + /// + /// Temporary directory path. + /// Serialized service provider item. + /// Service provider item id. + /// Service provider item type. + /// Service provider item name. + /// Service provider item package. + /// Service provider item service id. + /// Service provider item resource group. + /// Resulting code. + public int RestoreItem(string tempFolder, XmlNode itemNode, int itemId, Type itemType, string itemName, int packageId, int serviceId, ResourceGroupInfo group) + { + if (itemType == typeof(SharePointSiteCollection)) + { + HostedSharePointServer hostedSharePointServer = GetHostedSharePointServer(serviceId); + // Deserialize item. + XmlSerializer serializer = new XmlSerializer(typeof(SharePointSiteCollection)); + SharePointSiteCollection siteCollection = (SharePointSiteCollection)serializer.Deserialize(new XmlNodeReader(itemNode.SelectSingleNode("SharePointSiteCollection"))); + siteCollection.PackageId = packageId; + siteCollection.ServiceId = serviceId; - // Create site collection if needed. - if (hostedSharePointServer.GetSiteCollection(siteCollection.Url) == null) - { - hostedSharePointServer.CreateSiteCollection(siteCollection); - } + // Create site collection if needed. + if (hostedSharePointServer.GetSiteCollection(siteCollection.Url) == null) + { + hostedSharePointServer.CreateSiteCollection(siteCollection); + } + + // Add metabase record if needed. + SharePointSiteCollection metaSiteCollection = (SharePointSiteCollection)PackageController.GetPackageItemByName(packageId, itemName, typeof(SharePointSiteCollection)); + if (metaSiteCollection == null) + { + PackageController.AddPackageItem(siteCollection); + } + } + + return 0; + } - // Add metabase record if needed. - SharePointSiteCollection metaSiteCollection = (SharePointSiteCollection)PackageController.GetPackageItemByName(packageId, itemName, typeof(SharePointSiteCollection)); - if (metaSiteCollection == null) - { - PackageController.AddPackageItem(siteCollection); - } - } - return 0; - } - - private static int GetHostedSharePointServiceId(int packageId) { return PackageController.GetPackageServiceId(packageId, ResourceGroups.HostedSharePoint); } - + private static List GetOrganizationSharePointSiteCollections(int orgId) { Organization org = OrganizationController.GetOrganization(orgId); @@ -776,18 +810,18 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint SharePointSiteCollectionListPaged siteCollections = GetSiteCollectionsPaged(org.PackageId, org.Id, String.Empty, String.Empty, String.Empty, 0, Int32.MaxValue); return siteCollections.SiteCollections; } - + private static int RecalculateStorageMaxSize(int size, int packageId) - { + { PackageContext cntx = PackageController.GetPackageContext(packageId); - QuotaValueInfo quota = cntx.Quotas[Quotas.HOSTED_SHAREPOINT_STORAGE_SIZE]; + QuotaValueInfo quota = cntx.Quotas[Quotas.HOSTED_SHAREPOINT_STORAGE_SIZE]; if (quota.QuotaAllocatedValue == -1) { if (size == -1)//Unlimited return -1; else - return size; + return size; } else { @@ -795,7 +829,7 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint return quota.QuotaAllocatedValue; return Math.Min(size, quota.QuotaAllocatedValue); - } + } } private static int RecalculateMaxSize(int parentSize, int realSize) @@ -815,8 +849,8 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint return Math.Min(parentSize, realSize); } - - + + public static int SetStorageSettings(int itemId, int maxStorage, int warningStorage, bool applyToSiteCollections) { // check account @@ -831,15 +865,15 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint { Organization org = (Organization)PackageController.GetPackageItem(itemId); if (org == null) - return 0; + return 0; // set limits int realMaxSizeValue = RecalculateStorageMaxSize(maxStorage, org.PackageId); org.MaxSharePointStorage = realMaxSizeValue; - org.WarningSharePointStorage = realMaxSizeValue == -1 ? -1 : Math.Min(warningStorage, realMaxSizeValue); - + org.WarningSharePointStorage = realMaxSizeValue == -1 ? -1 : Math.Min(warningStorage, realMaxSizeValue); + // save organization UpdateOrganization(org); @@ -851,9 +885,9 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint List currentOrgSiteCollection = GetOrganizationSharePointSiteCollections(org.Id); - - - foreach( SharePointSiteCollection siteCollection in currentOrgSiteCollection) + + + foreach (SharePointSiteCollection siteCollection in currentOrgSiteCollection) { try { @@ -861,17 +895,17 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint sc.MaxSiteStorage = realMaxSizeValue; sc.WarningStorage = realMaxSizeValue == -1 ? -1 : warningStorage; PackageController.UpdatePackageItem(sc); - + hostedSharePointServer.UpdateQuotas(siteCollection.PhysicalAddress, realMaxSizeValue, warningStorage); } - catch(Exception ex) + catch (Exception ex) { TaskManager.WriteError(ex); } - } + } } - + return 0; } catch (Exception ex) @@ -894,14 +928,14 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint { errorCode = accountCheck; return null; - } + } // place log record TaskManager.StartTask("HOSTED_SHAREPOINT", "CALCULATE_DISK_SPACE"); TaskManager.ItemId = itemId; try { - Organization org = (Organization) PackageController.GetPackageItem(itemId); + Organization org = (Organization)PackageController.GetPackageItem(itemId); if (org == null) return null; @@ -917,7 +951,7 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint { urls.Add(siteCollection.PhysicalAddress); } - if (urls.Count > 0) + if (urls.Count > 0) retDiskSpace = hostedSharePointServer.CalculateSiteCollectionsDiskSpace(urls.ToArray()); else { @@ -927,7 +961,7 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint retDiskSpace[0].Url = string.Empty; } } - catch(Exception ex) + catch (Exception ex) { throw TaskManager.WriteError(ex); } @@ -935,10 +969,10 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint { TaskManager.CompleteTask(); } - return retDiskSpace; + return retDiskSpace; } - private static void UpdateOrganization(Organization organization) + private static void UpdateOrganization(Organization organization) { PackageController.UpdatePackageItem(organization); } @@ -949,7 +983,7 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint TaskManager.StartTask("HOSTED_SHAREPOINT", "UPDATE_QUOTA"); try { - Organization org = (Organization) PackageController.GetPackageItem(itemId); + Organization org = (Organization)PackageController.GetPackageItem(itemId); if (org == null) return; @@ -960,7 +994,7 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint SharePointSiteCollection sc = GetSiteCollection(siteCollectionId); int maxSize = RecalculateMaxSize(org.MaxSharePointStorage, maxStorage); - int warningSize = warningStorage; + int warningSize = warningStorage; sc.MaxSiteStorage = maxSize; @@ -970,7 +1004,7 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint hostedSharePointServer.UpdateQuotas(sc.PhysicalAddress, maxSize, warningStorage); } - catch(Exception ex) + catch (Exception ex) { throw TaskManager.WriteError(ex); } @@ -989,5 +1023,5 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint return (SecurityContext.CheckAccount(DemandAccount.NotDemo) < 0); } } - } + } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/OrganizationUser.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/OrganizationUser.cs index 228bf436..687c96cf 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/OrganizationUser.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/OrganizationUser.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2012, Outercurve Foundation. +// Copyright (c) 2011, Outercurve Foundation. // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, @@ -30,15 +30,15 @@ using System; namespace WebsitePanel.Providers.HostedSolution { - - + + public class OrganizationUser { private int accountId; private int itemId; private int packageId; - private string primaryEmailAddress; + private string primaryEmailAddress; private string accountPassword; private string samAccountName; private string displayName; @@ -65,18 +65,23 @@ namespace WebsitePanel.Providers.HostedSolution private string domainUserName; private bool disabled; + private bool locked; + private bool isOCSUser; + private bool isBlackBerryUser; + private bool isLyncUser; + ExchangeAccountType accountType; private OrganizationUser manager; private Guid crmUserId; - + public Guid CrmUserId { get { return crmUserId; } set { crmUserId = value; } } - + public string DomainUserName { @@ -98,10 +103,10 @@ namespace WebsitePanel.Providers.HostedSolution public bool Disabled { - get { return disabled;} - set { disabled = value;} + get { return disabled; } + set { disabled = value; } } - + public string FirstName { get { return firstName; } @@ -258,17 +263,40 @@ namespace WebsitePanel.Providers.HostedSolution set { primaryEmailAddress = value; } } - + public string AccountPassword { get { return accountPassword; } set { accountPassword = value; } } - public string ExternalEmail { get; set; } + public string ExternalEmail { get; set; } public string DistinguishedName { get; set; } - public bool Locked { get; set; } + public bool Locked + { + get { return locked; } + set { locked = value; } + } + + public bool IsOCSUser + { + get { return isOCSUser; } + set { isOCSUser = value; } + } + + public bool IsLyncUser + { + get { return isLyncUser; } + set { isLyncUser = value; } + } + + public bool IsBlackBerryUser + { + get { return isBlackBerryUser; } + set { isBlackBerryUser = value; } + } + } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/SharePoint/IHostedSharePointServer.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/SharePoint/IHostedSharePointServer.cs index 219e0301..16b4822e 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/SharePoint/IHostedSharePointServer.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/SharePoint/IHostedSharePointServer.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2012, Outercurve Foundation. +// Copyright (c) 2011, Outercurve Foundation. // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, @@ -30,89 +30,91 @@ using System; namespace WebsitePanel.Providers.SharePoint { - /// - /// Exposes functionality for share point server provider hosted in conjunction with organization management provider and - /// exchange server. - /// - public interface IHostedSharePointServer - { - /// - /// When implemented gets root web application uri. - /// - Uri RootWebApplicationUri - { - get; - } + /// + /// Exposes functionality for share point server provider hosted in conjunction with organization management provider and + /// exchange server. + /// + public interface IHostedSharePointServer + { + /// + /// When implemented gets root web application uri. + /// + Uri RootWebApplicationUri + { + get; + } - /// - /// When implemented gets list of supported languages by this installation of SharePoint. - /// - /// List of supported languages - int[] GetSupportedLanguages(); + /// + /// When implemented gets list of supported languages by this installation of SharePoint. + /// + /// List of supported languages + int[] GetSupportedLanguages(); - /// - /// When implemented gets list of SharePoint collections within root web application. - /// - /// List of SharePoint collections within root web application. - SharePointSiteCollection[] GetSiteCollections(); + /// + /// When implemented gets list of SharePoint collections within root web application. + /// + /// List of SharePoint collections within root web application. + SharePointSiteCollection[] GetSiteCollections(); - /// - /// When implemented gets SharePoint collection within root web application with given name. - /// - /// Url that uniquely identifies site collection to be loaded. - /// SharePoint collection within root web application with given name. - SharePointSiteCollection GetSiteCollection(string url); + /// + /// When implemented gets SharePoint collection within root web application with given name. + /// + /// Url that uniquely identifies site collection to be loaded. + /// SharePoint collection within root web application with given name. + SharePointSiteCollection GetSiteCollection(string url); - /// - /// When implemented creates site collection within predefined root web application. - /// - /// Information about site coolection to be created. - void CreateSiteCollection(SharePointSiteCollection siteCollection); - - /// - /// When implemented deletes site collection under given url. - /// - /// Url that uniquely identifies site collection to be deleted. - void DeleteSiteCollection(string url); + /// + /// When implemented creates site collection within predefined root web application. + /// + /// Information about site coolection to be created. + void CreateSiteCollection(SharePointSiteCollection siteCollection); - /// - /// When implemeneted backups site collection under give url. - /// - /// Url that uniquely identifies site collection to be deleted. - /// Resulting backup file name. - /// A value which shows whether created backup must be archived. - /// Created backup full path. - string BackupSiteCollection(string url, string filename, bool zip); + /// + /// When implemented deletes site collection under given url. + /// + /// Url that uniquely identifies site collection to be deleted. + void DeleteSiteCollection(SharePointSiteCollection siteCollection); - /// - /// When implemented restores site collection under given url from backup. - /// - /// Site collection to be restored. - /// Backup file name to restore from. - void RestoreSiteCollection(SharePointSiteCollection siteCollection, string filename); + /// + /// When implemeneted backups site collection under give url. + /// + /// Url that uniquely identifies site collection to be deleted. + /// Resulting backup file name. + /// A value which shows whether created backup must be archived. + /// Created backup full path. + string BackupSiteCollection(string url, string filename, bool zip); + + /// + /// When implemented restores site collection under given url from backup. + /// + /// Site collection to be restored. + /// Backup file name to restore from. + void RestoreSiteCollection(SharePointSiteCollection siteCollection, string filename); + + /// + /// When implemented gets binary data chunk of specified size from specified offset. + /// + /// Path to file to get bunary data chunk from. + /// Offset from which to start data reading. + /// Binary data chunk length. + /// Binary data chunk read from file. + byte[] GetTempFileBinaryChunk(string path, int offset, int length); + + /// + /// When implemented appends supplied binary data chunk to file. + /// + /// Non existent file name to append to. + /// Full path to existent file to append to. + /// Binary data chunk to append to. + /// Path to file that was appended with chunk. + string AppendTempFileBinaryChunk(string fileName, string path, byte[] chunk); - /// - /// When implemented gets binary data chunk of specified size from specified offset. - /// - /// Path to file to get bunary data chunk from. - /// Offset from which to start data reading. - /// Binary data chunk length. - /// Binary data chunk read from file. - byte[] GetTempFileBinaryChunk(string path, int offset, int length); - - /// - /// When implemented appends supplied binary data chunk to file. - /// - /// Non existent file name to append to. - /// Full path to existent file to append to. - /// Binary data chunk to append to. - /// Path to file that was appended with chunk. - string AppendTempFileBinaryChunk(string fileName, string path, byte[] chunk); - void UpdateQuotas(string url, long maxStorage, long warningStorage); - SharePointSiteDiskSpace[] CalculateSiteCollectionsDiskSpace(string[] urls); + SharePointSiteDiskSpace[] CalculateSiteCollectionsDiskSpace(string[] urls); - long GetSiteCollectionSize(string url); - } + long GetSiteCollectionSize(string url); + + void SetPeoplePickerOu(string site, string ou); + } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/SharePoint/SharePointSiteCollection.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/SharePoint/SharePointSiteCollection.cs index 77133bf8..120863c3 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/SharePoint/SharePointSiteCollection.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/SharePoint/SharePointSiteCollection.cs @@ -51,6 +51,9 @@ namespace WebsitePanel.Providers.SharePoint private long diskspace; private long maxSiteStorage; private long warningStorage; + private string rootWebApplicationInteralIpAddress; + private string rootWebApplicationFQDN; + [Persistent] @@ -178,6 +181,39 @@ namespace WebsitePanel.Providers.SharePoint } } + /// + /// Gets or sets the internal ip address + /// + [Persistent] + public string RootWebApplicationInteralIpAddress + { + get + { + return this.rootWebApplicationInteralIpAddress; + } + set + { + this.rootWebApplicationInteralIpAddress = value; + } + } + + /// + /// Gets or sets the internal ip address + /// + [Persistent] + public string RootWebApplicationFQDN + { + get + { + return this.rootWebApplicationFQDN; + } + set + { + this.rootWebApplicationFQDN = value; + } + } + + /// /// Gets or sets locale id of the site collection to be created. /// diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/HostedSharePointServer.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/HostedSharePointServer.cs index a162f2fa..3639da0b 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/HostedSharePointServer.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/HostedSharePointServer.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2012, Outercurve Foundation. +// Copyright (c) 2011, Outercurve Foundation. // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, @@ -36,14 +36,14 @@ using Microsoft.Win32; namespace WebsitePanel.Providers.HostedSolution { - /// - /// Provides hosted SharePoint server functionality implementation. - /// - public class HostedSharePointServer : HostingServiceProviderBase, IHostedSharePointServer - { - private delegate TReturn SharePointAction(HostedSharePointServerImpl impl); + /// + /// Provides hosted SharePoint server functionality implementation. + /// + public class HostedSharePointServer : HostingServiceProviderBase, IHostedSharePointServer + { + private delegate TReturn SharePointAction(HostedSharePointServerImpl impl); - protected string Wss3RegistryKey; + protected string Wss3RegistryKey; protected string Wss3Registry32Key; protected string LanguagePacksPath; @@ -54,301 +54,301 @@ namespace WebsitePanel.Providers.HostedSolution this.LanguagePacksPath = @"%commonprogramfiles%\microsoft shared\Web Server Extensions\12\HCCab\"; } - /// - /// Gets root web application uri. - /// - public Uri RootWebApplicationUri - { - get - { - return new Uri(ProviderSettings["RootWebApplicationUri"]); - } - } + /// + /// Gets root web application uri. + /// + public Uri RootWebApplicationUri + { + get + { + return new Uri(ProviderSettings["RootWebApplicationUri"]); + } + } public string BackupTemporaryFolder - { - get - { + { + get + { return ProviderSettings["BackupTemporaryFolder"]; - } - } + } + } - /// - /// Gets list of supported languages by this installation of SharePoint. - /// - /// List of supported languages - public int[] GetSupportedLanguages() - { - HostedSharePointServerImpl impl = new HostedSharePointServerImpl(); - return impl.GetSupportedLanguages(LanguagePacksPath); - } + /// + /// Gets list of supported languages by this installation of SharePoint. + /// + /// List of supported languages + public int[] GetSupportedLanguages() + { + HostedSharePointServerImpl impl = new HostedSharePointServerImpl(); + return impl.GetSupportedLanguages(LanguagePacksPath); + } - /// - /// Gets list of SharePoint collections within root web application. - /// - /// List of SharePoint collections within root web application. - public SharePointSiteCollection[] GetSiteCollections() - { - return - ExecuteSharePointAction(delegate(HostedSharePointServerImpl impl) - { - return impl.GetSiteCollections(RootWebApplicationUri); - }); - } + /// + /// Gets list of SharePoint collections within root web application. + /// + /// List of SharePoint collections within root web application. + public SharePointSiteCollection[] GetSiteCollections() + { + return + ExecuteSharePointAction(delegate(HostedSharePointServerImpl impl) + { + return impl.GetSiteCollections(RootWebApplicationUri); + }); + } - /// - /// Gets SharePoint collection within root web application with given name. - /// - /// Url that uniquely identifies site collection to be loaded. - /// SharePoint collection within root web application with given name. - public SharePointSiteCollection GetSiteCollection(string url) - { - return - ExecuteSharePointAction(delegate(HostedSharePointServerImpl impl) - { - return impl.GetSiteCollection(RootWebApplicationUri, url); - }); - } + /// + /// Gets SharePoint collection within root web application with given name. + /// + /// Url that uniquely identifies site collection to be loaded. + /// SharePoint collection within root web application with given name. + public SharePointSiteCollection GetSiteCollection(string url) + { + return + ExecuteSharePointAction(delegate(HostedSharePointServerImpl impl) + { + return impl.GetSiteCollection(RootWebApplicationUri, url); + }); + } - /// - /// Creates site collection within predefined root web application. - /// - /// Information about site coolection to be created. - public void CreateSiteCollection(SharePointSiteCollection siteCollection) - { - ExecuteSharePointAction(delegate(HostedSharePointServerImpl impl) - { - impl.CreateSiteCollection(RootWebApplicationUri, siteCollection); - return null; - }); - } + /// + /// Creates site collection within predefined root web application. + /// + /// Information about site coolection to be created. + public void CreateSiteCollection(SharePointSiteCollection siteCollection) + { + ExecuteSharePointAction(delegate(HostedSharePointServerImpl impl) + { + impl.CreateSiteCollection(RootWebApplicationUri, siteCollection); + return null; + }); + } - /// - /// Deletes site collection under given url. - /// - /// Url that uniquely identifies site collection to be deleted. - public void DeleteSiteCollection(string url) - { - ExecuteSharePointAction(delegate(HostedSharePointServerImpl impl) - { - impl.DeleteSiteCollection(RootWebApplicationUri, url); - return null; - }); - } + /// + /// Deletes site collection under given url. + /// + /// Url that uniquely identifies site collection to be deleted. + public void DeleteSiteCollection(SharePointSiteCollection siteCollection) + { + ExecuteSharePointAction(delegate(HostedSharePointServerImpl impl) + { + impl.DeleteSiteCollection(RootWebApplicationUri, siteCollection); + return null; + }); + } - /// - /// Backups site collection under give url. - /// - /// Url that uniquely identifies site collection to be deleted. - /// Resulting backup file name. - /// A value which shows whether created backup must be archived. - /// Created backup full path. - public string BackupSiteCollection(string url, string filename, bool zip) - { - return ExecuteSharePointAction(delegate(HostedSharePointServerImpl impl) - { - return impl.BackupSiteCollection(RootWebApplicationUri, url, filename, zip, BackupTemporaryFolder); - }); - } + /// + /// Backups site collection under give url. + /// + /// Url that uniquely identifies site collection to be deleted. + /// Resulting backup file name. + /// A value which shows whether created backup must be archived. + /// Created backup full path. + public string BackupSiteCollection(string url, string filename, bool zip) + { + return ExecuteSharePointAction(delegate(HostedSharePointServerImpl impl) + { + return impl.BackupSiteCollection(RootWebApplicationUri, url, filename, zip, BackupTemporaryFolder); + }); + } - - /// - /// Restores site collection under given url from backup. - /// - /// Site collection to be restored. - /// Backup file name to restore from. - public void RestoreSiteCollection(SharePointSiteCollection siteCollection, string filename) - { - ExecuteSharePointAction(delegate(HostedSharePointServerImpl impl) - { - impl.RestoreSiteCollection(RootWebApplicationUri, siteCollection, filename); - return null; - }); - } - /// - /// Gets binary data chunk of specified size from specified offset. - /// - /// Path to file to get bunary data chunk from. - /// Offset from which to start data reading. - /// Binary data chunk length. - /// Binary data chunk read from file. - public virtual byte[] GetTempFileBinaryChunk(string path, int offset, int length) - { - byte[] buffer = FileUtils.GetFileBinaryChunk(path, offset, length); + /// + /// Restores site collection under given url from backup. + /// + /// Site collection to be restored. + /// Backup file name to restore from. + public void RestoreSiteCollection(SharePointSiteCollection siteCollection, string filename) + { + ExecuteSharePointAction(delegate(HostedSharePointServerImpl impl) + { + impl.RestoreSiteCollection(RootWebApplicationUri, siteCollection, filename); + return null; + }); + } - // Delete temp file - if (buffer.Length < length) - { - FileUtils.DeleteFile(path); - } - return buffer; - } + /// + /// Gets binary data chunk of specified size from specified offset. + /// + /// Path to file to get bunary data chunk from. + /// Offset from which to start data reading. + /// Binary data chunk length. + /// Binary data chunk read from file. + public virtual byte[] GetTempFileBinaryChunk(string path, int offset, int length) + { + byte[] buffer = FileUtils.GetFileBinaryChunk(path, offset, length); - /// - /// Appends supplied binary data chunk to file. - /// - /// Non existent file name to append to. - /// Full path to existent file to append to. - /// Binary data chunk to append to. - /// Path to file that was appended with chunk. - public virtual string AppendTempFileBinaryChunk(string fileName, string path, byte[] chunk) - { - if (path == null) - { - path = Path.Combine(Path.GetTempPath(), fileName); - if (FileUtils.FileExists(path)) - { - FileUtils.DeleteFile(path); - } - } + // Delete temp file + if (buffer.Length < length) + { + FileUtils.DeleteFile(path); + } + return buffer; + } - FileUtils.AppendFileBinaryContent(path, chunk); + /// + /// Appends supplied binary data chunk to file. + /// + /// Non existent file name to append to. + /// Full path to existent file to append to. + /// Binary data chunk to append to. + /// Path to file that was appended with chunk. + public virtual string AppendTempFileBinaryChunk(string fileName, string path, byte[] chunk) + { + if (path == null) + { + path = Path.Combine(Path.GetTempPath(), fileName); + if (FileUtils.FileExists(path)) + { + FileUtils.DeleteFile(path); + } + } + + FileUtils.AppendFileBinaryContent(path, chunk); + + return path; + } - return path; - } - public override bool IsInstalled() { return IsSharePointInstalled(); - + } - /// - /// Deletes service items that represent SharePoint site collection. - /// - /// Items to be deleted. - public override void DeleteServiceItems(ServiceProviderItem[] items) - { - foreach (ServiceProviderItem item in items) - { - if (item is SharePointSiteCollection) - { - try - { - DeleteSiteCollection((item as SharePointSiteCollection).Url); - } - catch (Exception ex) - { - Log.WriteError(String.Format("Error deleting '{0}' {1}", item.Name, item.GetType().Name), ex); - } - } - } - } + /// + /// Deletes service items that represent SharePoint site collection. + /// + /// Items to be deleted. + public override void DeleteServiceItems(ServiceProviderItem[] items) + { + foreach (ServiceProviderItem item in items) + { + if (item is SharePointSiteCollection) + { + try + { + DeleteSiteCollection((SharePointSiteCollection)item); + } + catch (Exception ex) + { + Log.WriteError(String.Format("Error deleting '{0}' {1}", item.Name, item.GetType().Name), ex); + } + } + } + } - /// - /// Calculates diskspace used by supplied service items. - /// - /// Service items to get diskspace usage for. - /// Calculated disk space usage statistics. - public override ServiceProviderItemDiskSpace[] GetServiceItemsDiskSpace(ServiceProviderItem[] items) - { - List itemsDiskspace = new List(); + /// + /// Calculates diskspace used by supplied service items. + /// + /// Service items to get diskspace usage for. + /// Calculated disk space usage statistics. + public override ServiceProviderItemDiskSpace[] GetServiceItemsDiskSpace(ServiceProviderItem[] items) + { + List itemsDiskspace = new List(); - // update items with diskspace - foreach (ServiceProviderItem item in items) - { - if (item is SharePointSiteCollection) - { - try - { - Log.WriteStart(String.Format("Calculating '{0}' site logs size", item.Name)); + // update items with diskspace + foreach (ServiceProviderItem item in items) + { + if (item is SharePointSiteCollection) + { + try + { + Log.WriteStart(String.Format("Calculating '{0}' site logs size", item.Name)); - SharePointSiteCollection site = GetSiteCollection(item.Name); - ServiceProviderItemDiskSpace diskspace = new ServiceProviderItemDiskSpace(); - diskspace.ItemId = item.Id; - diskspace.DiskSpace = site.Diskspace; - itemsDiskspace.Add(diskspace); + SharePointSiteCollection site = GetSiteCollection(item.Name); + ServiceProviderItemDiskSpace diskspace = new ServiceProviderItemDiskSpace(); + diskspace.ItemId = item.Id; + diskspace.DiskSpace = site.Diskspace; + itemsDiskspace.Add(diskspace); - Log.WriteEnd(String.Format("Calculating '{0}' site logs size", item.Name)); - } - catch (Exception ex) - { - Log.WriteError(ex); - } - } - } - return itemsDiskspace.ToArray(); - } + Log.WriteEnd(String.Format("Calculating '{0}' site logs size", item.Name)); + } + catch (Exception ex) + { + Log.WriteError(ex); + } + } + } + return itemsDiskspace.ToArray(); + } - /// - /// Checks whether Wss 3.0 is installed. - /// - /// true - if it is installed; false - otherwise. - private bool IsSharePointInstalled() - { - RegistryKey spKey = Registry.LocalMachine.OpenSubKey(Wss3RegistryKey); + /// + /// Checks whether Wss 3.0 is installed. + /// + /// true - if it is installed; false - otherwise. + private bool IsSharePointInstalled() + { + RegistryKey spKey = Registry.LocalMachine.OpenSubKey(Wss3RegistryKey); RegistryKey spKey32 = Registry.LocalMachine.OpenSubKey(Wss3Registry32Key); if (spKey == null && spKey32 == null) - { - return false; - } + { + return false; + } - string spVal = (string)spKey.GetValue("SharePoint"); - return (String.Compare(spVal, "installed", true) == 0); - } + string spVal = (string)spKey.GetValue("SharePoint"); + return (String.Compare(spVal, "installed", true) == 0); + } - /// - /// Executes supplied action within separate application domain. - /// - /// Action to be executed. - /// Any object that results from action execution or null if nothing is supposed to be returned. - /// Is thrown in case supplied action is null. - private static TReturn ExecuteSharePointAction(SharePointAction action) - { - if (action == null) - { - throw new ArgumentNullException("action"); - } + /// + /// Executes supplied action within separate application domain. + /// + /// Action to be executed. + /// Any object that results from action execution or null if nothing is supposed to be returned. + /// Is thrown in case supplied action is null. + private static TReturn ExecuteSharePointAction(SharePointAction action) + { + if (action == null) + { + throw new ArgumentNullException("action"); + } - AppDomain domain = null; - try - { - // Create instance of server implementation in a separate application domain for - // security and isolation purposes. - Type type = typeof (HostedSharePointServerImpl); - AppDomainSetup info = new AppDomainSetup(); - info.ApplicationBase = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); - info.PrivateBinPath = "bin; bin/debug"; - domain = AppDomain.CreateDomain("WSS30", null, info); + AppDomain domain = null; + try + { + // Create instance of server implementation in a separate application domain for + // security and isolation purposes. + Type type = typeof(HostedSharePointServerImpl); + AppDomainSetup info = new AppDomainSetup(); + info.ApplicationBase = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); + info.PrivateBinPath = "bin; bin/debug"; + domain = AppDomain.CreateDomain("WSS30", null, info); - HostedSharePointServerImpl impl = - (HostedSharePointServerImpl) - domain.CreateInstanceAndUnwrap(type.Assembly.FullName, type.FullName); + HostedSharePointServerImpl impl = + (HostedSharePointServerImpl) + domain.CreateInstanceAndUnwrap(type.Assembly.FullName, type.FullName); - // Execute requested action within created application domain. - return action(impl); - } - finally - { - if (domain != null) - { - AppDomain.Unload(domain); - } - } - } + // Execute requested action within created application domain. + return action(impl); + } + finally + { + if (domain != null) + { + AppDomain.Unload(domain); + } + } + } public void UpdateQuotas(string url, long maxStorage, long warningStorage) { ExecuteSharePointAction(delegate(HostedSharePointServerImpl impl) - { - impl.UpdateQuotas(RootWebApplicationUri, url, maxStorage, warningStorage); - return null; - }); - - + { + impl.UpdateQuotas(RootWebApplicationUri, url, maxStorage, warningStorage); + return null; + }); + + + - } - public SharePointSiteDiskSpace[] CalculateSiteCollectionsDiskSpace(string []urls) + public SharePointSiteDiskSpace[] CalculateSiteCollectionsDiskSpace(string[] urls) { - SharePointSiteDiskSpace []sd = null; + SharePointSiteDiskSpace[] sd = null; sd = ExecuteSharePointAction(delegate(HostedSharePointServerImpl impl) - { - return impl.CalculateSiteCollectionDiskSpace(RootWebApplicationUri, urls); - }); + { + return impl.CalculateSiteCollectionDiskSpace(RootWebApplicationUri, urls); + }); return sd; @@ -366,5 +366,10 @@ namespace WebsitePanel.Providers.HostedSolution return ret; } + public virtual void SetPeoplePickerOu(string site, string ou) + { + + } + } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/HostedSharePointServer2010.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/HostedSharePointServer2010.cs index 0ae7dda3..b761df53 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/HostedSharePointServer2010.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/HostedSharePointServer2010.cs @@ -1,7 +1,18 @@ using System; +using System.IO; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Text; +using System.Management.Automation; +using System.Management.Automation.Runspaces; + +using WebsitePanel.Providers.Utils; +using WebsitePanel.Server.Utils; + +using WebsitePanel.Providers.SharePoint; + + namespace WebsitePanel.Providers.HostedSolution { public class HostedSharePointServer2010 : HostedSharePointServer @@ -12,5 +23,239 @@ namespace WebsitePanel.Providers.HostedSolution this.Wss3Registry32Key = @"SOFTWARE\Wow6432Node\Microsoft\Shared Tools\Web Server Extensions\14.0"; this.LanguagePacksPath = @"%commonprogramfiles%\microsoft shared\Web Server Extensions\14\HCCab\"; } + + #region PowerShell integration + private static RunspaceConfiguration runspaceConfiguration = null; + + internal virtual string SharepointSnapInName + { + get { return "Microsoft.SharePoint.Powershell"; } + } + + internal virtual Runspace OpenRunspace() + { + HostedSolutionLog.LogStart("OpenRunspace"); + + if (runspaceConfiguration == null) + { + runspaceConfiguration = RunspaceConfiguration.Create(); + PSSnapInException exception = null; + + PSSnapInInfo info = runspaceConfiguration.AddPSSnapIn(SharepointSnapInName, out exception); + HostedSolutionLog.LogInfo("Sharepoint snapin loaded"); + + if (exception != null) + { + HostedSolutionLog.LogWarning("SnapIn error", exception); + } + } + Runspace runSpace = RunspaceFactory.CreateRunspace(runspaceConfiguration); + // + runSpace.Open(); + // + runSpace.SessionStateProxy.SetVariable("ConfirmPreference", "none"); + HostedSolutionLog.LogEnd("OpenRunspace"); + return runSpace; + } + + internal void CloseRunspace(Runspace runspace) + { + try + { + if (runspace != null && runspace.RunspaceStateInfo.State == RunspaceState.Opened) + { + runspace.Close(); + } + } + catch (Exception ex) + { + HostedSolutionLog.LogError("Runspace error", ex); + } + } + + internal Collection ExecuteShellCommand(Runspace runSpace, Command cmd) + { + return ExecuteShellCommand(runSpace, cmd, true); + } + + internal Collection ExecuteShellCommand(Runspace runSpace, Command cmd, bool useDomainController) + { + object[] errors; + return ExecuteShellCommand(runSpace, cmd, useDomainController, out errors); + } + + internal Collection ExecuteShellCommand(Runspace runSpace, Command cmd, out object[] errors) + { + return ExecuteShellCommand(runSpace, cmd, true, out errors); + } + + internal Collection ExecuteShellCommand(Runspace runSpace, Command cmd, bool useDomainController, out object[] errors) + { + HostedSolutionLog.LogStart("ExecuteShellCommand"); + List errorList = new List(); + + HostedSolutionLog.DebugCommand(cmd); + Collection results = null; + // Create a pipeline + Pipeline pipeLine = runSpace.CreatePipeline(); + using (pipeLine) + { + // Add the command + pipeLine.Commands.Add(cmd); + // Execute the pipeline and save the objects returned. + results = pipeLine.Invoke(); + + // Log out any errors in the pipeline execution + // NOTE: These errors are NOT thrown as exceptions! + // Be sure to check this to ensure that no errors + // happened while executing the command. + if (pipeLine.Error != null && pipeLine.Error.Count > 0) + { + foreach (object item in pipeLine.Error.ReadToEnd()) + { + errorList.Add(item); + string errorMessage = string.Format("Invoke error: {0}", item); + HostedSolutionLog.LogWarning(errorMessage); + } + } + } + pipeLine = null; + errors = errorList.ToArray(); + HostedSolutionLog.LogEnd("ExecuteShellCommand"); + return results; + } + + /// + /// Returns the distinguished name of the object from the shell execution result + /// + /// + /// + internal string GetResultObjectDN(Collection result) + { + HostedSolutionLog.LogStart("GetResultObjectDN"); + if (result == null) + throw new ArgumentNullException("result", "Execution result is not specified"); + + if (result.Count < 1) + throw new ArgumentException("Execution result does not contain any object"); + + if (result.Count > 1) + throw new ArgumentException("Execution result contains more than one object"); + + PSMemberInfo info = result[0].Members["DistinguishedName"]; + if (info == null) + throw new ArgumentException("Execution result does not contain DistinguishedName property", "result"); + + string ret = info.Value.ToString(); + HostedSolutionLog.LogEnd("GetResultObjectDN"); + return ret; + } + + /// + /// Checks the object from the shell execution result. + /// + /// + /// Distinguished name of the object if object exists or null otherwise. + internal string CheckResultObjectDN(Collection result) + { + HostedSolutionLog.LogStart("CheckResultObjectDN"); + + if (result == null) + return null; + + if (result.Count < 1) + return null; + + PSMemberInfo info = result[0].Members["DistinguishedName"]; + if (info == null) + throw new ArgumentException("Execution result does not contain DistinguishedName property", "result"); + + string ret = info.Value.ToString(); + HostedSolutionLog.LogEnd("CheckResultObjectDN"); + return ret; + } + + /// + /// Returns the identity of the object from the shell execution result + /// + /// + /// + internal string GetResultObjectIdentity(Collection result) + { + HostedSolutionLog.LogStart("GetResultObjectIdentity"); + if (result == null) + throw new ArgumentNullException("result", "Execution result is not specified"); + + if (result.Count < 1) + throw new ArgumentException("Execution result is empty", "result"); + + if (result.Count > 1) + throw new ArgumentException("Execution result contains more than one object", "result"); + + PSMemberInfo info = result[0].Members["Identity"]; + if (info == null) + throw new ArgumentException("Execution result does not contain Identity property", "result"); + + string ret = info.Value.ToString(); + HostedSolutionLog.LogEnd("GetResultObjectIdentity"); + return ret; + } + + /// + /// Returns the identity of the PS object + /// + /// + /// + internal string GetPSObjectIdentity(PSObject obj) + { + HostedSolutionLog.LogStart("GetPSObjectIdentity"); + if (obj == null) + throw new ArgumentNullException("obj", "PSObject is not specified"); + + + PSMemberInfo info = obj.Members["Identity"]; + if (info == null) + throw new ArgumentException("PSObject does not contain Identity property", "obj"); + + string ret = info.Value.ToString(); + HostedSolutionLog.LogEnd("GetPSObjectIdentity"); + return ret; + } + + internal object GetPSObjectProperty(PSObject obj, string name) + { + return obj.Members[name].Value; + } + + #endregion + + public override void SetPeoplePickerOu(string site, string ou) + { + HostedSolutionLog.LogStart("SetPeoplePickerOu"); + HostedSolutionLog.LogInfo(" Site: {0}", site); + HostedSolutionLog.LogInfo(" OU: {0}", ou); + + Runspace runSpace = null; + try + { + List siteCollections = new List(); + + runSpace = OpenRunspace(); + Command cmd = new Command("Set-SPSite"); + cmd.Parameters.Add("Identity", site); + cmd.Parameters.Add("UserAccountDirectoryPath", ou); + ExecuteShellCommand(runSpace, cmd); + + } + finally + { + + CloseRunspace(runSpace); + } + + HostedSolutionLog.LogEnd("SetPeoplePickerOu"); + } + + } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/HostedSharePointServerImpl.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/HostedSharePointServerImpl.cs index e947279b..f9f15cdf 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/HostedSharePointServerImpl.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/HostedSharePointServerImpl.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2012, Outercurve Foundation. +// Copyright (c) 2011, Outercurve Foundation. // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, @@ -38,33 +38,48 @@ using Microsoft.SharePoint.Administration; namespace WebsitePanel.Providers.HostedSolution { - /// - /// Represents SharePoint management functionality implementation. - /// - public class HostedSharePointServerImpl : MarshalByRefObject - { - /// - /// Gets list of supported languages by this installation of SharePoint. - /// - /// List of supported languages + /// + /// Represents SharePoint management functionality implementation. + /// + public class HostedSharePointServerImpl : MarshalByRefObject + { + /// + /// Gets list of supported languages by this installation of SharePoint. + /// + /// List of supported languages public int[] GetSupportedLanguages(string languagePacksPath) - { - List languages = new List(); - string rootDirectory = FileUtils.EvaluateSystemVariables(languagePacksPath); - foreach (string dir in Directory.GetDirectories(rootDirectory)) - { - int languageId = 0; - if (Int32.TryParse(dir.Replace(rootDirectory, String.Empty), out languageId)) - { - languages.Add(languageId); - } - } + { + List languages = new List(); - return languages.ToArray(); - } + try + { + WindowsImpersonationContext wic = WindowsIdentity.GetCurrent().Impersonate(); - public long GetSiteCollectionSize(Uri root,string url) - { + try + { + SPLanguageCollection installedLanguages = SPRegionalSettings.GlobalInstalledLanguages; + + foreach (SPLanguage lang in installedLanguages) + { + languages.Add(lang.LCID); + } + + return languages.ToArray(); + + } + finally + { + wic.Undo(); + } + } + catch (Exception ex) + { + throw new InvalidOperationException("Failed to create site collection.", ex); + } + } + + public long GetSiteCollectionSize(Uri root, string url) + { WindowsImpersonationContext wic = null; try @@ -77,8 +92,8 @@ namespace WebsitePanel.Providers.HostedSolution site.RecalculateStorageUsed(); else throw new ApplicationException(string.Format("SiteCollection {0} does not exist", url)); - - return site.Usage.Storage; + + return site.Usage.Storage; } catch (Exception ex) { @@ -91,28 +106,28 @@ namespace WebsitePanel.Providers.HostedSolution wic.Undo(); } - } - + } + public SharePointSiteDiskSpace[] CalculateSiteCollectionDiskSpace(Uri root, string[] urls) - { + { WindowsImpersonationContext wic = null; - + try { wic = WindowsIdentity.GetCurrent().Impersonate(); - + SPWebApplication rootWebApplication = SPWebApplication.Lookup(root); List ret = new List(); foreach (string url in urls) { SharePointSiteDiskSpace siteDiskSpace = new SharePointSiteDiskSpace(); - rootWebApplication.Sites[url].RecalculateStorageUsed(); + rootWebApplication.Sites[url].RecalculateStorageUsed(); siteDiskSpace.Url = url; - siteDiskSpace.DiskSpace = (long)Math.Round( rootWebApplication.Sites[url].Usage.Storage / 1024.0 / 1024.0); + siteDiskSpace.DiskSpace = (long)Math.Round(rootWebApplication.Sites[url].Usage.Storage / 1024.0 / 1024.0); ret.Add(siteDiskSpace); } - return ret.ToArray(); + return ret.ToArray(); } catch (Exception ex) { @@ -125,97 +140,97 @@ namespace WebsitePanel.Providers.HostedSolution wic.Undo(); } - } - - + } + + /// - /// Gets list of SharePoint collections within root web application. - /// - /// Root web application uri. - /// List of SharePoint collections within root web application. - public SharePointSiteCollection[] GetSiteCollections(Uri rootWebApplicationUri) - { - try - { - WindowsImpersonationContext wic = WindowsIdentity.GetCurrent().Impersonate(); + /// Gets list of SharePoint collections within root web application. + /// + /// Root web application uri. + /// List of SharePoint collections within root web application. + public SharePointSiteCollection[] GetSiteCollections(Uri rootWebApplicationUri) + { + try + { + WindowsImpersonationContext wic = WindowsIdentity.GetCurrent().Impersonate(); - try - { - SPWebApplication rootWebApplication = SPWebApplication.Lookup(rootWebApplicationUri); + try + { + SPWebApplication rootWebApplication = SPWebApplication.Lookup(rootWebApplicationUri); - List siteCollections = new List(); + List siteCollections = new List(); - foreach(SPSite site in rootWebApplication.Sites) - { + foreach (SPSite site in rootWebApplication.Sites) + { SharePointSiteCollection loadedSiteCollection = new SharePointSiteCollection(); - FillSiteCollection(loadedSiteCollection, site); - siteCollections.Add(loadedSiteCollection); - } + FillSiteCollection(loadedSiteCollection, site); + siteCollections.Add(loadedSiteCollection); + } - return siteCollections.ToArray(); - } - finally - { - wic.Undo(); - } - } - catch (Exception ex) - { - throw new InvalidOperationException("Failed to create site collection.", ex); - } - } + return siteCollections.ToArray(); + } + finally + { + wic.Undo(); + } + } + catch (Exception ex) + { + throw new InvalidOperationException("Failed to create site collection.", ex); + } + } - /// - /// Gets SharePoint collection within root web application with given name. - /// - /// Root web application uri. - /// Url that uniquely identifies site collection to be loaded. - /// SharePoint collection within root web application with given name. - public SharePointSiteCollection GetSiteCollection(Uri rootWebApplicationUri, string url) - { - try - { - WindowsImpersonationContext wic = WindowsIdentity.GetCurrent().Impersonate(); + /// + /// Gets SharePoint collection within root web application with given name. + /// + /// Root web application uri. + /// Url that uniquely identifies site collection to be loaded. + /// SharePoint collection within root web application with given name. + public SharePointSiteCollection GetSiteCollection(Uri rootWebApplicationUri, string url) + { + try + { + WindowsImpersonationContext wic = WindowsIdentity.GetCurrent().Impersonate(); - try - { - SPWebApplication rootWebApplication = SPWebApplication.Lookup(rootWebApplicationUri); - string siteCollectionUrl = String.Format("{0}:{1}", url, rootWebApplicationUri.Port); - - SPSite site = rootWebApplication.Sites[siteCollectionUrl]; - if (site != null) - { - SharePointSiteCollection loadedSiteCollection = new SharePointSiteCollection(); - FillSiteCollection(loadedSiteCollection, site); - return loadedSiteCollection; - } - return null; - } - finally - { - wic.Undo(); - } - } - catch (Exception ex) - { - throw new InvalidOperationException("Failed to create site collection.", ex); - } - } + try + { + SPWebApplication rootWebApplication = SPWebApplication.Lookup(rootWebApplicationUri); + string siteCollectionUrl = String.Format("{0}:{1}", url, rootWebApplicationUri.Port); - private static void DeleteQuotaTemplate(string name) - { + SPSite site = rootWebApplication.Sites[siteCollectionUrl]; + if (site != null) + { + SharePointSiteCollection loadedSiteCollection = new SharePointSiteCollection(); + FillSiteCollection(loadedSiteCollection, site); + return loadedSiteCollection; + } + return null; + } + finally + { + wic.Undo(); + } + } + catch (Exception ex) + { + throw new InvalidOperationException("Failed to create site collection.", ex); + } + } + + private static void DeleteQuotaTemplate(string name) + { SPFarm farm = SPFarm.Local; SPWebService webService = farm.Services.GetValue(""); SPQuotaTemplateCollection quotaColl = webService.QuotaTemplates; - quotaColl.Delete(name); - } - + quotaColl.Delete(name); + } + public void UpdateQuotas(Uri root, string url, long maxStorage, long warningStorage) { WindowsImpersonationContext wic = null; - + try { wic = WindowsIdentity.GetCurrent().Impersonate(); @@ -230,10 +245,10 @@ namespace WebsitePanel.Providers.HostedSolution if (warningStorage != -1 && maxStorage != -1) - quota.StorageWarningLevel = Math.Min(warningStorage, maxStorage)*1024*1024; + quota.StorageWarningLevel = Math.Min(warningStorage, maxStorage) * 1024 * 1024; else quota.StorageWarningLevel = 0; - + rootWebApplication.GrantAccessToProcessIdentity(WindowsIdentity.GetCurrent().Name); rootWebApplication.Sites[url].Quota = quota; @@ -250,16 +265,17 @@ namespace WebsitePanel.Providers.HostedSolution } } - + /// - /// Creates site collection within predefined root web application. - /// - /// Root web application uri. - /// Information about site coolection to be created. - /// Is thrown in case requested operation fails for any reason. + /// Creates site collection within predefined root web application. + /// + /// Root web application uri. + /// Information about site coolection to be created. + /// Is thrown in case requested operation fails for any reason. public void CreateSiteCollection(Uri rootWebApplicationUri, SharePointSiteCollection siteCollection) { WindowsImpersonationContext wic = null; + HostedSolutionLog.LogStart("CreateSiteCollection"); try { @@ -267,27 +283,29 @@ namespace WebsitePanel.Providers.HostedSolution SPWebApplication rootWebApplication = SPWebApplication.Lookup(rootWebApplicationUri); string siteCollectionUrl = String.Format("{0}:{1}", siteCollection.Url, rootWebApplicationUri.Port); + HostedSolutionLog.DebugInfo("rootWebApplicationUri: {0}", rootWebApplicationUri); + HostedSolutionLog.DebugInfo("siteCollectionUrl: {0}", siteCollectionUrl); SPQuota spQuota; - + SPSite spSite = rootWebApplication.Sites.Add(siteCollectionUrl, siteCollection.Title, siteCollection.Description, - (uint) siteCollection.LocaleId, String.Empty, + (uint)siteCollection.LocaleId, String.Empty, siteCollection.OwnerLogin, siteCollection.OwnerName, siteCollection.OwnerEmail, null, null, null, true); try { - + spQuota = new SPQuota(); - + if (siteCollection.MaxSiteStorage != -1) spQuota.StorageMaximumLevel = siteCollection.MaxSiteStorage * 1024 * 1024; if (siteCollection.WarningStorage != -1 && siteCollection.MaxSiteStorage != -1) spQuota.StorageWarningLevel = Math.Min(siteCollection.WarningStorage, siteCollection.MaxSiteStorage) * 1024 * 1024; - + } catch (Exception) { @@ -298,7 +316,7 @@ namespace WebsitePanel.Providers.HostedSolution try { rootWebApplication.GrantAccessToProcessIdentity(WindowsIdentity.GetCurrent().Name); - spSite.Quota = spQuota; + spSite.Quota = spQuota; } catch (Exception) { @@ -308,8 +326,77 @@ namespace WebsitePanel.Providers.HostedSolution } rootWebApplication.Update(true); + + try + { + if (siteCollection.RootWebApplicationInteralIpAddress != string.Empty) + { + string dirPath = FileUtils.EvaluateSystemVariables(@"%windir%\system32\drivers\etc"); + string path = dirPath + "\\hosts"; + + if (FileUtils.FileExists(path)) + { + string content = FileUtils.GetFileTextContent(path); + content = content.Replace("\r\n", "\n").Replace("\n\r", "\n"); + string[] contentArr = content.Split(new char[] { '\n' }); + bool bRecordExist = false; + foreach (string s in contentArr) + { + if (s != string.Empty) + { + string IPAddr = string.Empty; + string hostName = string.Empty; + if (s[0] != '#') + { + bool bSeperator = false; + foreach (char c in s) + { + if ((c != ' ') & (c != '\t')) + { + if (bSeperator) + hostName += c; + else + IPAddr += c; + } + else + bSeperator = true; + } + + if (hostName.ToLower() == siteCollection.RootWebApplicationFQDN.ToLower()) + { + bRecordExist = true; + break; + } + + } + } + } + + if (!bRecordExist) + { + string outPut = string.Empty; + foreach (string o in contentArr) + { + if (o != string.Empty) + outPut += o + "\r\n"; + } + + outPut += siteCollection.RootWebApplicationInteralIpAddress + '\t' + siteCollection.RootWebApplicationFQDN + "\r\n"; + + FileUtils.UpdateFileTextContent(path, outPut); + } + + + } + } + } + catch (Exception ex) + { + HostedSolutionLog.LogError(ex); + + } } - catch(Exception ex) + catch (Exception ex) { HostedSolutionLog.LogError(ex); throw; @@ -318,207 +405,267 @@ namespace WebsitePanel.Providers.HostedSolution { if (wic != null) wic.Undo(); + + HostedSolutionLog.LogEnd("CreateSiteCollection"); } } - /// - /// Deletes site collection under given url. - /// - /// Root web application uri. - /// Url that uniquely identifies site collection to be deleted. - /// Is thrown in case requested operation fails for any reason. - public void DeleteSiteCollection(Uri rootWebApplicationUri, string url) - { - try - { - WindowsIdentity identity = WindowsIdentity.GetCurrent(); - WindowsImpersonationContext wic = identity.Impersonate(); + /// + /// Deletes site collection under given url. + /// + /// Root web application uri. + /// Url that uniquely identifies site collection to be deleted. + /// Is thrown in case requested operation fails for any reason. + public void DeleteSiteCollection(Uri rootWebApplicationUri, SharePointSiteCollection siteCollection) + { + try + { + WindowsIdentity identity = WindowsIdentity.GetCurrent(); + WindowsImpersonationContext wic = identity.Impersonate(); - try - { - SPWebApplication rootWebApplication = SPWebApplication.Lookup(rootWebApplicationUri); - string siteCollectionUrl = String.Format("{0}:{1}", url, rootWebApplicationUri.Port); + try + { + SPWebApplication rootWebApplication = SPWebApplication.Lookup(rootWebApplicationUri); + string siteCollectionUrl = String.Format("{0}:{1}", siteCollection.Url, rootWebApplicationUri.Port); - //string args = String.Format("-o deletesite -url {0}", siteCollectionUrl); - //string stsadm = @"c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\STSADM.EXE"; + //string args = String.Format("-o deletesite -url {0}", siteCollectionUrl); + //string stsadm = @"c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\STSADM.EXE"; - //// launch system process - //ProcessStartInfo startInfo = new ProcessStartInfo(stsadm, args); - //startInfo.WindowStyle = ProcessWindowStyle.Hidden; - //startInfo.RedirectStandardOutput = true; - //startInfo.UseShellExecute = false; - //Process proc = Process.Start(startInfo); + //// launch system process + //ProcessStartInfo startInfo = new ProcessStartInfo(stsadm, args); + //startInfo.WindowStyle = ProcessWindowStyle.Hidden; + //startInfo.RedirectStandardOutput = true; + //startInfo.UseShellExecute = false; + //Process proc = Process.Start(startInfo); - //// analyze results - //StreamReader reader = proc.StandardOutput; - //string output = reader.ReadToEnd(); - //int exitCode = proc.ExitCode; - //reader.Close(); + //// analyze results + //StreamReader reader = proc.StandardOutput; + //string output = reader.ReadToEnd(); + //int exitCode = proc.ExitCode; + //reader.Close(); - rootWebApplication.Sites.Delete(siteCollectionUrl, true); - rootWebApplication.Update(true); - } - finally - { - wic.Undo(); - } - } - catch(Exception ex) - { - throw new InvalidOperationException("Failed to delete site collection.", ex); - } - } + rootWebApplication.Sites.Delete(siteCollectionUrl, true); + rootWebApplication.Update(true); - /// - /// Backups site collection under give url. - /// - /// Root web application uri. - /// Url that uniquely identifies site collection to be deleted. - /// Resulting backup file name. - /// A value which shows whether created backup must be archived. - /// Custom temp path for backup - /// Full path to created backup. - /// Is thrown in case requested operation fails for any reason. - public string BackupSiteCollection(Uri rootWebApplicationUri, string url, string filename, bool zip, string tempPath) - { - try - { - WindowsImpersonationContext wic = WindowsIdentity.GetCurrent().Impersonate(); + try + { + if (siteCollection.RootWebApplicationInteralIpAddress != string.Empty) + { + string dirPath = FileUtils.EvaluateSystemVariables(@"%windir%\system32\drivers\etc"); + string path = dirPath + "\\hosts"; - try - { - SPWebApplication rootWebApplication = SPWebApplication.Lookup(rootWebApplicationUri); - string siteCollectionUrl = String.Format("{0}:{1}", url, rootWebApplicationUri.Port); + if (FileUtils.FileExists(path)) + { + string content = FileUtils.GetFileTextContent(path); + content = content.Replace("\r\n", "\n").Replace("\n\r", "\n"); + string[] contentArr = content.Split(new char[] { '\n' }); + string outPut = string.Empty; + foreach (string s in contentArr) + { + if (s != string.Empty) + { + string IPAddr = string.Empty; + string hostName = string.Empty; + if (s[0] != '#') + { + bool bSeperator = false; + foreach (char c in s) + { + if ((c != ' ') & (c != '\t')) + { + if (bSeperator) + hostName += c; + else + IPAddr += c; + } + else + bSeperator = true; + } - if (String.IsNullOrEmpty(tempPath)) - { - tempPath = Path.GetTempPath(); - } - string backupFileName = Path.Combine(tempPath, (zip ? StringUtils.CleanIdentifier(siteCollectionUrl) + ".bsh" : StringUtils.CleanIdentifier(filename))); - // Backup requested site. - rootWebApplication.Sites.Backup(siteCollectionUrl, backupFileName, true); + if (hostName.ToLower() != siteCollection.RootWebApplicationFQDN.ToLower()) + { + outPut += s + "\r\n"; + } - if (zip) - { - string zipFile = Path.Combine(tempPath, filename); - string zipRoot = Path.GetDirectoryName(backupFileName); + } + else + outPut += s + "\r\n"; + } + } - FileUtils.ZipFiles(zipFile, zipRoot, new string[] { Path.GetFileName(backupFileName) }); - FileUtils.DeleteFile(backupFileName); + FileUtils.UpdateFileTextContent(path, outPut); + } + } + } + catch (Exception ex) + { + HostedSolutionLog.LogError(ex); - backupFileName = zipFile; - } - return backupFileName; - } - finally - { - wic.Undo(); - } - } - catch(Exception ex) - { - throw new InvalidOperationException("Failed to backup site collection.", ex); - } - } - - /// - /// Restores site collection under given url from backup. - /// - /// Root web application uri. - /// Site collection to be restored. - /// Backup file name to restore from. - /// Is thrown in case requested operation fails for any reason. - public void RestoreSiteCollection(Uri rootWebApplicationUri, SharePointSiteCollection siteCollection, string filename) - { - string url = siteCollection.Url; - try - { - - WindowsImpersonationContext wic = WindowsIdentity.GetCurrent().Impersonate(); - - try - { - SPWebApplication rootWebApplication = SPWebApplication.Lookup(rootWebApplicationUri); - string siteCollectionUrl = String.Format("{0}:{1}", url, rootWebApplicationUri.Port); - - string tempPath = Path.GetTempPath(); - // Unzip uploaded files if required. - string expandedFile = filename; - if (Path.GetExtension(filename).ToLower() == ".zip") - { - // Unpack file. - expandedFile = FileUtils.UnzipFiles(filename, tempPath)[0]; - - // Delete zip archive. - FileUtils.DeleteFile(filename); - } - - // Delete existent site and restore new one. - rootWebApplication.Sites.Delete(siteCollectionUrl, false); - rootWebApplication.Sites.Restore(siteCollectionUrl, expandedFile, true, true); - - SPSite restoredSite = rootWebApplication.Sites[siteCollectionUrl]; - SPWeb web = restoredSite.OpenWeb(); - - SPUser owner = null; - try - { - owner = web.SiteUsers[siteCollection.OwnerLogin]; - } - catch - { - // Ignore this error. - } - if (owner == null) - { - web.SiteUsers.Add(siteCollection.OwnerLogin, siteCollection.OwnerEmail, siteCollection.OwnerName, String.Empty); - owner = web.SiteUsers[siteCollection.OwnerLogin]; - } - - restoredSite.Owner = owner; - web.Close(); - - rootWebApplication.Update(); - - // Delete expanded file. - FileUtils.DeleteFile(expandedFile); - } - finally - { - wic.Undo(); - } - } - catch(Exception ex) - { - throw new InvalidOperationException("Failed to restore site collection.", ex); - } - } + } - /// - /// Fills custom site collection with information from administration object. - /// - /// Custom site collection to fill. - /// Administration object. - private static void FillSiteCollection (SharePointSiteCollection customSiteCollection, SPSite site) - { - Uri siteUri = new Uri(site.Url); - string url = (siteUri.Port > 0) ? site.Url.Replace(String.Format(":{0}", siteUri.Port), String.Empty) : site.Url; + } + finally + { + wic.Undo(); + } + } + catch (Exception ex) + { + throw new InvalidOperationException("Failed to delete site collection.", ex); + } + } - customSiteCollection.Url = url; - customSiteCollection.OwnerLogin = site.Owner.LoginName; - customSiteCollection.OwnerName = site.Owner.Name; - customSiteCollection.OwnerEmail = site.Owner.Email; - customSiteCollection.LocaleId = site.RootWeb.Locale.LCID; - customSiteCollection.Title = site.RootWeb.Title; - customSiteCollection.Description = site.RootWeb.Description; - customSiteCollection.Bandwidth = site.Usage.Bandwidth; - customSiteCollection.Diskspace = site.Usage.Storage; - customSiteCollection.MaxSiteStorage = site.Quota.StorageMaximumLevel; - customSiteCollection.WarningStorage = site.Quota.StorageWarningLevel; - } - } + /// + /// Backups site collection under give url. + /// + /// Root web application uri. + /// Url that uniquely identifies site collection to be deleted. + /// Resulting backup file name. + /// A value which shows whether created backup must be archived. + /// Custom temp path for backup + /// Full path to created backup. + /// Is thrown in case requested operation fails for any reason. + public string BackupSiteCollection(Uri rootWebApplicationUri, string url, string filename, bool zip, string tempPath) + { + try + { + WindowsImpersonationContext wic = WindowsIdentity.GetCurrent().Impersonate(); + + try + { + SPWebApplication rootWebApplication = SPWebApplication.Lookup(rootWebApplicationUri); + string siteCollectionUrl = String.Format("{0}:{1}", url, rootWebApplicationUri.Port); + + if (String.IsNullOrEmpty(tempPath)) + { + tempPath = Path.GetTempPath(); + } + string backupFileName = Path.Combine(tempPath, (zip ? StringUtils.CleanIdentifier(siteCollectionUrl) + ".bsh" : StringUtils.CleanIdentifier(filename))); + // Backup requested site. + rootWebApplication.Sites.Backup(siteCollectionUrl, backupFileName, true); + + if (zip) + { + string zipFile = Path.Combine(tempPath, filename); + string zipRoot = Path.GetDirectoryName(backupFileName); + + FileUtils.ZipFiles(zipFile, zipRoot, new string[] { Path.GetFileName(backupFileName) }); + FileUtils.DeleteFile(backupFileName); + + backupFileName = zipFile; + } + return backupFileName; + } + finally + { + wic.Undo(); + } + } + catch (Exception ex) + { + throw new InvalidOperationException("Failed to backup site collection.", ex); + } + } + + /// + /// Restores site collection under given url from backup. + /// + /// Root web application uri. + /// Site collection to be restored. + /// Backup file name to restore from. + /// Is thrown in case requested operation fails for any reason. + public void RestoreSiteCollection(Uri rootWebApplicationUri, SharePointSiteCollection siteCollection, string filename) + { + string url = siteCollection.Url; + try + { + + WindowsImpersonationContext wic = WindowsIdentity.GetCurrent().Impersonate(); + + try + { + SPWebApplication rootWebApplication = SPWebApplication.Lookup(rootWebApplicationUri); + string siteCollectionUrl = String.Format("{0}:{1}", url, rootWebApplicationUri.Port); + + string tempPath = Path.GetTempPath(); + // Unzip uploaded files if required. + string expandedFile = filename; + if (Path.GetExtension(filename).ToLower() == ".zip") + { + // Unpack file. + expandedFile = FileUtils.UnzipFiles(filename, tempPath)[0]; + + // Delete zip archive. + FileUtils.DeleteFile(filename); + } + + // Delete existent site and restore new one. + rootWebApplication.Sites.Delete(siteCollectionUrl, false); + rootWebApplication.Sites.Restore(siteCollectionUrl, expandedFile, true, true); + + SPSite restoredSite = rootWebApplication.Sites[siteCollectionUrl]; + SPWeb web = restoredSite.OpenWeb(); + + SPUser owner = null; + try + { + owner = web.SiteUsers[siteCollection.OwnerLogin]; + } + catch + { + // Ignore this error. + } + if (owner == null) + { + web.SiteUsers.Add(siteCollection.OwnerLogin, siteCollection.OwnerEmail, siteCollection.OwnerName, String.Empty); + owner = web.SiteUsers[siteCollection.OwnerLogin]; + } + + restoredSite.Owner = owner; + web.Close(); + + rootWebApplication.Update(); + + // Delete expanded file. + FileUtils.DeleteFile(expandedFile); + } + finally + { + wic.Undo(); + } + } + catch (Exception ex) + { + throw new InvalidOperationException("Failed to restore site collection.", ex); + } + } + + + /// + /// Fills custom site collection with information from administration object. + /// + /// Custom site collection to fill. + /// Administration object. + private static void FillSiteCollection(SharePointSiteCollection customSiteCollection, SPSite site) + { + Uri siteUri = new Uri(site.Url); + string url = (siteUri.Port > 0) ? site.Url.Replace(String.Format(":{0}", siteUri.Port), String.Empty) : site.Url; + + customSiteCollection.Url = url; + customSiteCollection.OwnerLogin = site.Owner.LoginName; + customSiteCollection.OwnerName = site.Owner.Name; + customSiteCollection.OwnerEmail = site.Owner.Email; + customSiteCollection.LocaleId = site.RootWeb.Locale.LCID; + customSiteCollection.Title = site.RootWeb.Title; + customSiteCollection.Description = site.RootWeb.Description; + customSiteCollection.Bandwidth = site.Usage.Bandwidth; + customSiteCollection.Diskspace = site.Usage.Storage; + customSiteCollection.MaxSiteStorage = site.Quota.StorageMaximumLevel; + customSiteCollection.WarningStorage = site.Quota.StorageWarningLevel; + } + } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/HostedSolutionLog.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/HostedSolutionLog.cs index 51267394..4ad0ce27 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/HostedSolutionLog.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/HostedSolutionLog.cs @@ -29,6 +29,8 @@ using System; using WebsitePanel.Providers.Common; using WebsitePanel.Server.Utils; +using System.Text; +using System.Management.Automation.Runspaces; namespace WebsitePanel.Providers.HostedSolution { @@ -121,6 +123,22 @@ namespace WebsitePanel.Providers.HostedSolution res.IsSuccess = true; return res; } + + internal static void DebugCommand(Command cmd) + { + StringBuilder sb = new StringBuilder(cmd.CommandText); + foreach (CommandParameter parameter in cmd.Parameters) + { + string formatString = " -{0} {1}"; + if (parameter.Value is string) + formatString = " -{0} '{1}'"; + else if (parameter.Value is bool) + formatString = " -{0} ${1}"; + sb.AppendFormat(formatString, parameter.Name, parameter.Value); + } + Log.WriteInfo("{0} {1}", LogPrefix, sb.ToString()); + } + } } diff --git a/WebsitePanel/Sources/WebsitePanel.Server.Client/HostedSharePointServerProxy.cs b/WebsitePanel/Sources/WebsitePanel.Server.Client/HostedSharePointServerProxy.cs index fa6a5f6d..2cb383e5 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server.Client/HostedSharePointServerProxy.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server.Client/HostedSharePointServerProxy.cs @@ -1,35 +1,7 @@ -// Copyright (c) 2012, Outercurve Foundation. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: -// -// - Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// -// - Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// - Neither the name of the Outercurve Foundation nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.1433 +// Runtime Version:2.0.50727.5448 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -39,283 +11,328 @@ // // This source code was auto-generated by wsdl, Version=2.0.50727.42. // -using WebsitePanel.Providers.SharePoint; - -namespace WebsitePanel.Providers.HostedSolution { - using System.Diagnostics; +namespace WebsitePanel.Providers.HostedSolution +{ + using System.Xml.Serialization; using System.Web.Services; using System.ComponentModel; using System.Web.Services.Protocols; using System; - using System.Xml.Serialization; - - + using System.Diagnostics; + using WebsitePanel.Providers.SharePoint; + + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] - [System.Web.Services.WebServiceBindingAttribute(Name="HostedSharePointServerSoap", Namespace="http://smbsaas/websitepanel/server/")] + [System.Web.Services.WebServiceBindingAttribute(Name = "HostedSharePointServerSoap", Namespace = "http://smbsaas/websitepanel/server/")] [System.Xml.Serialization.XmlIncludeAttribute(typeof(ServiceProviderItem))] - public partial class HostedSharePointServer : Microsoft.Web.Services3.WebServicesClientProtocol { - + public partial class HostedSharePointServer : Microsoft.Web.Services3.WebServicesClientProtocol + { + public ServiceProviderSettingsSoapHeader ServiceProviderSettingsSoapHeaderValue; - + private System.Threading.SendOrPostCallback GetSupportedLanguagesOperationCompleted; - + private System.Threading.SendOrPostCallback GetSiteCollectionsOperationCompleted; - + private System.Threading.SendOrPostCallback GetSiteCollectionOperationCompleted; - + private System.Threading.SendOrPostCallback CreateSiteCollectionOperationCompleted; - + private System.Threading.SendOrPostCallback UpdateQuotasOperationCompleted; - + private System.Threading.SendOrPostCallback CalculateSiteCollectionsDiskSpaceOperationCompleted; - + private System.Threading.SendOrPostCallback DeleteSiteCollectionOperationCompleted; - + private System.Threading.SendOrPostCallback BackupSiteCollectionOperationCompleted; - + private System.Threading.SendOrPostCallback RestoreSiteCollectionOperationCompleted; - + private System.Threading.SendOrPostCallback GetTempFileBinaryChunkOperationCompleted; - + private System.Threading.SendOrPostCallback AppendTempFileBinaryChunkOperationCompleted; - + private System.Threading.SendOrPostCallback GetSiteCollectionSizeOperationCompleted; - + + private System.Threading.SendOrPostCallback SetPeoplePickerOuOperationCompleted; + /// - public HostedSharePointServer() { - this.Url = "http://192.168.0.132:9003/HostedSharePointServer.asmx"; + public HostedSharePointServer() + { + this.Url = "http://localhost:9003/HostedSharePointServer.asmx"; } - + /// public event GetSupportedLanguagesCompletedEventHandler GetSupportedLanguagesCompleted; - + /// public event GetSiteCollectionsCompletedEventHandler GetSiteCollectionsCompleted; - + /// public event GetSiteCollectionCompletedEventHandler GetSiteCollectionCompleted; - + /// public event CreateSiteCollectionCompletedEventHandler CreateSiteCollectionCompleted; - + /// public event UpdateQuotasCompletedEventHandler UpdateQuotasCompleted; - + /// public event CalculateSiteCollectionsDiskSpaceCompletedEventHandler CalculateSiteCollectionsDiskSpaceCompleted; - + /// public event DeleteSiteCollectionCompletedEventHandler DeleteSiteCollectionCompleted; - + /// public event BackupSiteCollectionCompletedEventHandler BackupSiteCollectionCompleted; - + /// public event RestoreSiteCollectionCompletedEventHandler RestoreSiteCollectionCompleted; - + /// public event GetTempFileBinaryChunkCompletedEventHandler GetTempFileBinaryChunkCompleted; - + /// public event AppendTempFileBinaryChunkCompletedEventHandler AppendTempFileBinaryChunkCompleted; - + /// public event GetSiteCollectionSizeCompletedEventHandler GetSiteCollectionSizeCompleted; - + + /// + public event SetPeoplePickerOuCompletedEventHandler SetPeoplePickerOuCompleted; + /// [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/GetSupportedLanguages", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public int[] GetSupportedLanguages() { + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/GetSupportedLanguages", RequestNamespace = "http://smbsaas/websitepanel/server/", ResponseNamespace = "http://smbsaas/websitepanel/server/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public int[] GetSupportedLanguages() + { object[] results = this.Invoke("GetSupportedLanguages", new object[0]); return ((int[])(results[0])); } - + /// - public System.IAsyncResult BeginGetSupportedLanguages(System.AsyncCallback callback, object asyncState) { + public System.IAsyncResult BeginGetSupportedLanguages(System.AsyncCallback callback, object asyncState) + { return this.BeginInvoke("GetSupportedLanguages", new object[0], callback, asyncState); } - + /// - public int[] EndGetSupportedLanguages(System.IAsyncResult asyncResult) { + public int[] EndGetSupportedLanguages(System.IAsyncResult asyncResult) + { object[] results = this.EndInvoke(asyncResult); return ((int[])(results[0])); } - + /// - public void GetSupportedLanguagesAsync() { + public void GetSupportedLanguagesAsync() + { this.GetSupportedLanguagesAsync(null); } - + /// - public void GetSupportedLanguagesAsync(object userState) { - if ((this.GetSupportedLanguagesOperationCompleted == null)) { + public void GetSupportedLanguagesAsync(object userState) + { + if ((this.GetSupportedLanguagesOperationCompleted == null)) + { this.GetSupportedLanguagesOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetSupportedLanguagesOperationCompleted); } this.InvokeAsync("GetSupportedLanguages", new object[0], this.GetSupportedLanguagesOperationCompleted, userState); } - - private void OnGetSupportedLanguagesOperationCompleted(object arg) { - if ((this.GetSupportedLanguagesCompleted != null)) { + + private void OnGetSupportedLanguagesOperationCompleted(object arg) + { + if ((this.GetSupportedLanguagesCompleted != null)) + { System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); this.GetSupportedLanguagesCompleted(this, new GetSupportedLanguagesCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); } } - + /// [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/GetSiteCollections", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public SharePointSiteCollection[] GetSiteCollections() { + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/GetSiteCollections", RequestNamespace = "http://smbsaas/websitepanel/server/", ResponseNamespace = "http://smbsaas/websitepanel/server/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public SharePointSiteCollection[] GetSiteCollections() + { object[] results = this.Invoke("GetSiteCollections", new object[0]); return ((SharePointSiteCollection[])(results[0])); } - + /// - public System.IAsyncResult BeginGetSiteCollections(System.AsyncCallback callback, object asyncState) { + public System.IAsyncResult BeginGetSiteCollections(System.AsyncCallback callback, object asyncState) + { return this.BeginInvoke("GetSiteCollections", new object[0], callback, asyncState); } - + /// - public SharePointSiteCollection[] EndGetSiteCollections(System.IAsyncResult asyncResult) { + public SharePointSiteCollection[] EndGetSiteCollections(System.IAsyncResult asyncResult) + { object[] results = this.EndInvoke(asyncResult); return ((SharePointSiteCollection[])(results[0])); } - + /// - public void GetSiteCollectionsAsync() { + public void GetSiteCollectionsAsync() + { this.GetSiteCollectionsAsync(null); } - + /// - public void GetSiteCollectionsAsync(object userState) { - if ((this.GetSiteCollectionsOperationCompleted == null)) { + public void GetSiteCollectionsAsync(object userState) + { + if ((this.GetSiteCollectionsOperationCompleted == null)) + { this.GetSiteCollectionsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetSiteCollectionsOperationCompleted); } this.InvokeAsync("GetSiteCollections", new object[0], this.GetSiteCollectionsOperationCompleted, userState); } - - private void OnGetSiteCollectionsOperationCompleted(object arg) { - if ((this.GetSiteCollectionsCompleted != null)) { + + private void OnGetSiteCollectionsOperationCompleted(object arg) + { + if ((this.GetSiteCollectionsCompleted != null)) + { System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); this.GetSiteCollectionsCompleted(this, new GetSiteCollectionsCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); } } - + /// [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/GetSiteCollection", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public SharePointSiteCollection GetSiteCollection(string url) { + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/GetSiteCollection", RequestNamespace = "http://smbsaas/websitepanel/server/", ResponseNamespace = "http://smbsaas/websitepanel/server/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public SharePointSiteCollection GetSiteCollection(string url) + { object[] results = this.Invoke("GetSiteCollection", new object[] { url}); return ((SharePointSiteCollection)(results[0])); } - + /// - public System.IAsyncResult BeginGetSiteCollection(string url, System.AsyncCallback callback, object asyncState) { + public System.IAsyncResult BeginGetSiteCollection(string url, System.AsyncCallback callback, object asyncState) + { return this.BeginInvoke("GetSiteCollection", new object[] { url}, callback, asyncState); } - + /// - public SharePointSiteCollection EndGetSiteCollection(System.IAsyncResult asyncResult) { + public SharePointSiteCollection EndGetSiteCollection(System.IAsyncResult asyncResult) + { object[] results = this.EndInvoke(asyncResult); return ((SharePointSiteCollection)(results[0])); } - + /// - public void GetSiteCollectionAsync(string url) { + public void GetSiteCollectionAsync(string url) + { this.GetSiteCollectionAsync(url, null); } - + /// - public void GetSiteCollectionAsync(string url, object userState) { - if ((this.GetSiteCollectionOperationCompleted == null)) { + public void GetSiteCollectionAsync(string url, object userState) + { + if ((this.GetSiteCollectionOperationCompleted == null)) + { this.GetSiteCollectionOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetSiteCollectionOperationCompleted); } this.InvokeAsync("GetSiteCollection", new object[] { url}, this.GetSiteCollectionOperationCompleted, userState); } - - private void OnGetSiteCollectionOperationCompleted(object arg) { - if ((this.GetSiteCollectionCompleted != null)) { + + private void OnGetSiteCollectionOperationCompleted(object arg) + { + if ((this.GetSiteCollectionCompleted != null)) + { System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); this.GetSiteCollectionCompleted(this, new GetSiteCollectionCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); } } - + /// [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/CreateSiteCollection", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public void CreateSiteCollection(SharePointSiteCollection siteCollection) { + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/CreateSiteCollection", RequestNamespace = "http://smbsaas/websitepanel/server/", ResponseNamespace = "http://smbsaas/websitepanel/server/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public void CreateSiteCollection(SharePointSiteCollection siteCollection) + { this.Invoke("CreateSiteCollection", new object[] { siteCollection}); } - + /// - public System.IAsyncResult BeginCreateSiteCollection(SharePointSiteCollection siteCollection, System.AsyncCallback callback, object asyncState) { + public System.IAsyncResult BeginCreateSiteCollection(SharePointSiteCollection siteCollection, System.AsyncCallback callback, object asyncState) + { return this.BeginInvoke("CreateSiteCollection", new object[] { siteCollection}, callback, asyncState); } - + /// - public void EndCreateSiteCollection(System.IAsyncResult asyncResult) { + public void EndCreateSiteCollection(System.IAsyncResult asyncResult) + { this.EndInvoke(asyncResult); } - + /// - public void CreateSiteCollectionAsync(SharePointSiteCollection siteCollection) { + public void CreateSiteCollectionAsync(SharePointSiteCollection siteCollection) + { this.CreateSiteCollectionAsync(siteCollection, null); } - + /// - public void CreateSiteCollectionAsync(SharePointSiteCollection siteCollection, object userState) { - if ((this.CreateSiteCollectionOperationCompleted == null)) { + public void CreateSiteCollectionAsync(SharePointSiteCollection siteCollection, object userState) + { + if ((this.CreateSiteCollectionOperationCompleted == null)) + { this.CreateSiteCollectionOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreateSiteCollectionOperationCompleted); } this.InvokeAsync("CreateSiteCollection", new object[] { siteCollection}, this.CreateSiteCollectionOperationCompleted, userState); } - - private void OnCreateSiteCollectionOperationCompleted(object arg) { - if ((this.CreateSiteCollectionCompleted != null)) { + + private void OnCreateSiteCollectionOperationCompleted(object arg) + { + if ((this.CreateSiteCollectionCompleted != null)) + { System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); this.CreateSiteCollectionCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); } } - + /// [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/UpdateQuotas", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public void UpdateQuotas(string url, long maxSize, long warningSize) { + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/UpdateQuotas", RequestNamespace = "http://smbsaas/websitepanel/server/", ResponseNamespace = "http://smbsaas/websitepanel/server/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public void UpdateQuotas(string url, long maxSize, long warningSize) + { this.Invoke("UpdateQuotas", new object[] { url, maxSize, warningSize}); } - + /// - public System.IAsyncResult BeginUpdateQuotas(string url, long maxSize, long warningSize, System.AsyncCallback callback, object asyncState) { + public System.IAsyncResult BeginUpdateQuotas(string url, long maxSize, long warningSize, System.AsyncCallback callback, object asyncState) + { return this.BeginInvoke("UpdateQuotas", new object[] { url, maxSize, warningSize}, callback, asyncState); } - + /// - public void EndUpdateQuotas(System.IAsyncResult asyncResult) { + public void EndUpdateQuotas(System.IAsyncResult asyncResult) + { this.EndInvoke(asyncResult); } - + /// - public void UpdateQuotasAsync(string url, long maxSize, long warningSize) { + public void UpdateQuotasAsync(string url, long maxSize, long warningSize) + { this.UpdateQuotasAsync(url, maxSize, warningSize, null); } - + /// - public void UpdateQuotasAsync(string url, long maxSize, long warningSize, object userState) { - if ((this.UpdateQuotasOperationCompleted == null)) { + public void UpdateQuotasAsync(string url, long maxSize, long warningSize, object userState) + { + if ((this.UpdateQuotasOperationCompleted == null)) + { this.UpdateQuotasOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUpdateQuotasOperationCompleted); } this.InvokeAsync("UpdateQuotas", new object[] { @@ -323,129 +340,153 @@ namespace WebsitePanel.Providers.HostedSolution { maxSize, warningSize}, this.UpdateQuotasOperationCompleted, userState); } - - private void OnUpdateQuotasOperationCompleted(object arg) { - if ((this.UpdateQuotasCompleted != null)) { + + private void OnUpdateQuotasOperationCompleted(object arg) + { + if ((this.UpdateQuotasCompleted != null)) + { System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); this.UpdateQuotasCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); } } - + /// [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/CalculateSiteCollectionsDiskSpace", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public SharePointSiteDiskSpace[] CalculateSiteCollectionsDiskSpace(string[] urls) { + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/CalculateSiteCollectionsDiskSpace", RequestNamespace = "http://smbsaas/websitepanel/server/", ResponseNamespace = "http://smbsaas/websitepanel/server/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public SharePointSiteDiskSpace[] CalculateSiteCollectionsDiskSpace(string[] urls) + { object[] results = this.Invoke("CalculateSiteCollectionsDiskSpace", new object[] { urls}); return ((SharePointSiteDiskSpace[])(results[0])); } - + /// - public System.IAsyncResult BeginCalculateSiteCollectionsDiskSpace(string[] urls, System.AsyncCallback callback, object asyncState) { + public System.IAsyncResult BeginCalculateSiteCollectionsDiskSpace(string[] urls, System.AsyncCallback callback, object asyncState) + { return this.BeginInvoke("CalculateSiteCollectionsDiskSpace", new object[] { urls}, callback, asyncState); } - + /// - public SharePointSiteDiskSpace[] EndCalculateSiteCollectionsDiskSpace(System.IAsyncResult asyncResult) { + public SharePointSiteDiskSpace[] EndCalculateSiteCollectionsDiskSpace(System.IAsyncResult asyncResult) + { object[] results = this.EndInvoke(asyncResult); return ((SharePointSiteDiskSpace[])(results[0])); } - + /// - public void CalculateSiteCollectionsDiskSpaceAsync(string[] urls) { + public void CalculateSiteCollectionsDiskSpaceAsync(string[] urls) + { this.CalculateSiteCollectionsDiskSpaceAsync(urls, null); } - + /// - public void CalculateSiteCollectionsDiskSpaceAsync(string[] urls, object userState) { - if ((this.CalculateSiteCollectionsDiskSpaceOperationCompleted == null)) { + public void CalculateSiteCollectionsDiskSpaceAsync(string[] urls, object userState) + { + if ((this.CalculateSiteCollectionsDiskSpaceOperationCompleted == null)) + { this.CalculateSiteCollectionsDiskSpaceOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCalculateSiteCollectionsDiskSpaceOperationCompleted); } this.InvokeAsync("CalculateSiteCollectionsDiskSpace", new object[] { urls}, this.CalculateSiteCollectionsDiskSpaceOperationCompleted, userState); } - - private void OnCalculateSiteCollectionsDiskSpaceOperationCompleted(object arg) { - if ((this.CalculateSiteCollectionsDiskSpaceCompleted != null)) { + + private void OnCalculateSiteCollectionsDiskSpaceOperationCompleted(object arg) + { + if ((this.CalculateSiteCollectionsDiskSpaceCompleted != null)) + { System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); this.CalculateSiteCollectionsDiskSpaceCompleted(this, new CalculateSiteCollectionsDiskSpaceCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); } } - + /// [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/DeleteSiteCollection", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public void DeleteSiteCollection(string url) { + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/DeleteSiteCollection", RequestNamespace = "http://smbsaas/websitepanel/server/", ResponseNamespace = "http://smbsaas/websitepanel/server/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public void DeleteSiteCollection(SharePointSiteCollection siteCollection) + { this.Invoke("DeleteSiteCollection", new object[] { - url}); + siteCollection}); } - + /// - public System.IAsyncResult BeginDeleteSiteCollection(string url, System.AsyncCallback callback, object asyncState) { + public System.IAsyncResult BeginDeleteSiteCollection(SharePointSiteCollection siteCollection, System.AsyncCallback callback, object asyncState) + { return this.BeginInvoke("DeleteSiteCollection", new object[] { - url}, callback, asyncState); + siteCollection}, callback, asyncState); } - + /// - public void EndDeleteSiteCollection(System.IAsyncResult asyncResult) { + public void EndDeleteSiteCollection(System.IAsyncResult asyncResult) + { this.EndInvoke(asyncResult); } - + /// - public void DeleteSiteCollectionAsync(string url) { - this.DeleteSiteCollectionAsync(url, null); + public void DeleteSiteCollectionAsync(SharePointSiteCollection siteCollection) + { + this.DeleteSiteCollectionAsync(siteCollection, null); } - + /// - public void DeleteSiteCollectionAsync(string url, object userState) { - if ((this.DeleteSiteCollectionOperationCompleted == null)) { + public void DeleteSiteCollectionAsync(SharePointSiteCollection siteCollection, object userState) + { + if ((this.DeleteSiteCollectionOperationCompleted == null)) + { this.DeleteSiteCollectionOperationCompleted = new System.Threading.SendOrPostCallback(this.OnDeleteSiteCollectionOperationCompleted); } this.InvokeAsync("DeleteSiteCollection", new object[] { - url}, this.DeleteSiteCollectionOperationCompleted, userState); + siteCollection}, this.DeleteSiteCollectionOperationCompleted, userState); } - - private void OnDeleteSiteCollectionOperationCompleted(object arg) { - if ((this.DeleteSiteCollectionCompleted != null)) { + + private void OnDeleteSiteCollectionOperationCompleted(object arg) + { + if ((this.DeleteSiteCollectionCompleted != null)) + { System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); this.DeleteSiteCollectionCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); } } - + /// [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/BackupSiteCollection", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public string BackupSiteCollection(string url, string filename, bool zip) { + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/BackupSiteCollection", RequestNamespace = "http://smbsaas/websitepanel/server/", ResponseNamespace = "http://smbsaas/websitepanel/server/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public string BackupSiteCollection(string url, string filename, bool zip) + { object[] results = this.Invoke("BackupSiteCollection", new object[] { url, filename, zip}); return ((string)(results[0])); } - + /// - public System.IAsyncResult BeginBackupSiteCollection(string url, string filename, bool zip, System.AsyncCallback callback, object asyncState) { + public System.IAsyncResult BeginBackupSiteCollection(string url, string filename, bool zip, System.AsyncCallback callback, object asyncState) + { return this.BeginInvoke("BackupSiteCollection", new object[] { url, filename, zip}, callback, asyncState); } - + /// - public string EndBackupSiteCollection(System.IAsyncResult asyncResult) { + public string EndBackupSiteCollection(System.IAsyncResult asyncResult) + { object[] results = this.EndInvoke(asyncResult); return ((string)(results[0])); } - + /// - public void BackupSiteCollectionAsync(string url, string filename, bool zip) { + public void BackupSiteCollectionAsync(string url, string filename, bool zip) + { this.BackupSiteCollectionAsync(url, filename, zip, null); } - + /// - public void BackupSiteCollectionAsync(string url, string filename, bool zip, object userState) { - if ((this.BackupSiteCollectionOperationCompleted == null)) { + public void BackupSiteCollectionAsync(string url, string filename, bool zip, object userState) + { + if ((this.BackupSiteCollectionOperationCompleted == null)) + { this.BackupSiteCollectionOperationCompleted = new System.Threading.SendOrPostCallback(this.OnBackupSiteCollectionOperationCompleted); } this.InvokeAsync("BackupSiteCollection", new object[] { @@ -453,91 +494,107 @@ namespace WebsitePanel.Providers.HostedSolution { filename, zip}, this.BackupSiteCollectionOperationCompleted, userState); } - - private void OnBackupSiteCollectionOperationCompleted(object arg) { - if ((this.BackupSiteCollectionCompleted != null)) { + + private void OnBackupSiteCollectionOperationCompleted(object arg) + { + if ((this.BackupSiteCollectionCompleted != null)) + { System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); this.BackupSiteCollectionCompleted(this, new BackupSiteCollectionCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); } } - + /// [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/RestoreSiteCollection", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public void RestoreSiteCollection(SharePointSiteCollection siteCollection, string filename) { + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/RestoreSiteCollection", RequestNamespace = "http://smbsaas/websitepanel/server/", ResponseNamespace = "http://smbsaas/websitepanel/server/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public void RestoreSiteCollection(SharePointSiteCollection siteCollection, string filename) + { this.Invoke("RestoreSiteCollection", new object[] { siteCollection, filename}); } - + /// - public System.IAsyncResult BeginRestoreSiteCollection(SharePointSiteCollection siteCollection, string filename, System.AsyncCallback callback, object asyncState) { + public System.IAsyncResult BeginRestoreSiteCollection(SharePointSiteCollection siteCollection, string filename, System.AsyncCallback callback, object asyncState) + { return this.BeginInvoke("RestoreSiteCollection", new object[] { siteCollection, filename}, callback, asyncState); } - + /// - public void EndRestoreSiteCollection(System.IAsyncResult asyncResult) { + public void EndRestoreSiteCollection(System.IAsyncResult asyncResult) + { this.EndInvoke(asyncResult); } - + /// - public void RestoreSiteCollectionAsync(SharePointSiteCollection siteCollection, string filename) { + public void RestoreSiteCollectionAsync(SharePointSiteCollection siteCollection, string filename) + { this.RestoreSiteCollectionAsync(siteCollection, filename, null); } - + /// - public void RestoreSiteCollectionAsync(SharePointSiteCollection siteCollection, string filename, object userState) { - if ((this.RestoreSiteCollectionOperationCompleted == null)) { + public void RestoreSiteCollectionAsync(SharePointSiteCollection siteCollection, string filename, object userState) + { + if ((this.RestoreSiteCollectionOperationCompleted == null)) + { this.RestoreSiteCollectionOperationCompleted = new System.Threading.SendOrPostCallback(this.OnRestoreSiteCollectionOperationCompleted); } this.InvokeAsync("RestoreSiteCollection", new object[] { siteCollection, filename}, this.RestoreSiteCollectionOperationCompleted, userState); } - - private void OnRestoreSiteCollectionOperationCompleted(object arg) { - if ((this.RestoreSiteCollectionCompleted != null)) { + + private void OnRestoreSiteCollectionOperationCompleted(object arg) + { + if ((this.RestoreSiteCollectionCompleted != null)) + { System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); this.RestoreSiteCollectionCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); } } - + /// [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/GetTempFileBinaryChunk", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - [return: System.Xml.Serialization.XmlElementAttribute(DataType="base64Binary")] - public byte[] GetTempFileBinaryChunk(string path, int offset, int length) { + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/GetTempFileBinaryChunk", RequestNamespace = "http://smbsaas/websitepanel/server/", ResponseNamespace = "http://smbsaas/websitepanel/server/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + [return: System.Xml.Serialization.XmlElementAttribute(DataType = "base64Binary")] + public byte[] GetTempFileBinaryChunk(string path, int offset, int length) + { object[] results = this.Invoke("GetTempFileBinaryChunk", new object[] { path, offset, length}); return ((byte[])(results[0])); } - + /// - public System.IAsyncResult BeginGetTempFileBinaryChunk(string path, int offset, int length, System.AsyncCallback callback, object asyncState) { + public System.IAsyncResult BeginGetTempFileBinaryChunk(string path, int offset, int length, System.AsyncCallback callback, object asyncState) + { return this.BeginInvoke("GetTempFileBinaryChunk", new object[] { path, offset, length}, callback, asyncState); } - + /// - public byte[] EndGetTempFileBinaryChunk(System.IAsyncResult asyncResult) { + public byte[] EndGetTempFileBinaryChunk(System.IAsyncResult asyncResult) + { object[] results = this.EndInvoke(asyncResult); return ((byte[])(results[0])); } - + /// - public void GetTempFileBinaryChunkAsync(string path, int offset, int length) { + public void GetTempFileBinaryChunkAsync(string path, int offset, int length) + { this.GetTempFileBinaryChunkAsync(path, offset, length, null); } - + /// - public void GetTempFileBinaryChunkAsync(string path, int offset, int length, object userState) { - if ((this.GetTempFileBinaryChunkOperationCompleted == null)) { + public void GetTempFileBinaryChunkAsync(string path, int offset, int length, object userState) + { + if ((this.GetTempFileBinaryChunkOperationCompleted == null)) + { this.GetTempFileBinaryChunkOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetTempFileBinaryChunkOperationCompleted); } this.InvokeAsync("GetTempFileBinaryChunk", new object[] { @@ -545,47 +602,55 @@ namespace WebsitePanel.Providers.HostedSolution { offset, length}, this.GetTempFileBinaryChunkOperationCompleted, userState); } - - private void OnGetTempFileBinaryChunkOperationCompleted(object arg) { - if ((this.GetTempFileBinaryChunkCompleted != null)) { + + private void OnGetTempFileBinaryChunkOperationCompleted(object arg) + { + if ((this.GetTempFileBinaryChunkCompleted != null)) + { System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); this.GetTempFileBinaryChunkCompleted(this, new GetTempFileBinaryChunkCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); } } - + /// [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/AppendTempFileBinaryChunk", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public string AppendTempFileBinaryChunk(string fileName, string path, [System.Xml.Serialization.XmlElementAttribute(DataType="base64Binary")] byte[] chunk) { + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/AppendTempFileBinaryChunk", RequestNamespace = "http://smbsaas/websitepanel/server/", ResponseNamespace = "http://smbsaas/websitepanel/server/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public string AppendTempFileBinaryChunk(string fileName, string path, [System.Xml.Serialization.XmlElementAttribute(DataType = "base64Binary")] byte[] chunk) + { object[] results = this.Invoke("AppendTempFileBinaryChunk", new object[] { fileName, path, chunk}); return ((string)(results[0])); } - + /// - public System.IAsyncResult BeginAppendTempFileBinaryChunk(string fileName, string path, byte[] chunk, System.AsyncCallback callback, object asyncState) { + public System.IAsyncResult BeginAppendTempFileBinaryChunk(string fileName, string path, byte[] chunk, System.AsyncCallback callback, object asyncState) + { return this.BeginInvoke("AppendTempFileBinaryChunk", new object[] { fileName, path, chunk}, callback, asyncState); } - + /// - public string EndAppendTempFileBinaryChunk(System.IAsyncResult asyncResult) { + public string EndAppendTempFileBinaryChunk(System.IAsyncResult asyncResult) + { object[] results = this.EndInvoke(asyncResult); return ((string)(results[0])); } - + /// - public void AppendTempFileBinaryChunkAsync(string fileName, string path, byte[] chunk) { + public void AppendTempFileBinaryChunkAsync(string fileName, string path, byte[] chunk) + { this.AppendTempFileBinaryChunkAsync(fileName, path, chunk, null); } - + /// - public void AppendTempFileBinaryChunkAsync(string fileName, string path, byte[] chunk, object userState) { - if ((this.AppendTempFileBinaryChunkOperationCompleted == null)) { + public void AppendTempFileBinaryChunkAsync(string fileName, string path, byte[] chunk, object userState) + { + if ((this.AppendTempFileBinaryChunkOperationCompleted == null)) + { this.AppendTempFileBinaryChunkOperationCompleted = new System.Threading.SendOrPostCallback(this.OnAppendTempFileBinaryChunkOperationCompleted); } this.InvokeAsync("AppendTempFileBinaryChunk", new object[] { @@ -593,287 +658,381 @@ namespace WebsitePanel.Providers.HostedSolution { path, chunk}, this.AppendTempFileBinaryChunkOperationCompleted, userState); } - - private void OnAppendTempFileBinaryChunkOperationCompleted(object arg) { - if ((this.AppendTempFileBinaryChunkCompleted != null)) { + + private void OnAppendTempFileBinaryChunkOperationCompleted(object arg) + { + if ((this.AppendTempFileBinaryChunkCompleted != null)) + { System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); this.AppendTempFileBinaryChunkCompleted(this, new AppendTempFileBinaryChunkCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); } } - + /// [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/GetSiteCollectionSize", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public long GetSiteCollectionSize(string url) { + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/GetSiteCollectionSize", RequestNamespace = "http://smbsaas/websitepanel/server/", ResponseNamespace = "http://smbsaas/websitepanel/server/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public long GetSiteCollectionSize(string url) + { object[] results = this.Invoke("GetSiteCollectionSize", new object[] { url}); return ((long)(results[0])); } - + /// - public System.IAsyncResult BeginGetSiteCollectionSize(string url, System.AsyncCallback callback, object asyncState) { + public System.IAsyncResult BeginGetSiteCollectionSize(string url, System.AsyncCallback callback, object asyncState) + { return this.BeginInvoke("GetSiteCollectionSize", new object[] { url}, callback, asyncState); } - + /// - public long EndGetSiteCollectionSize(System.IAsyncResult asyncResult) { + public long EndGetSiteCollectionSize(System.IAsyncResult asyncResult) + { object[] results = this.EndInvoke(asyncResult); return ((long)(results[0])); } - + /// - public void GetSiteCollectionSizeAsync(string url) { + public void GetSiteCollectionSizeAsync(string url) + { this.GetSiteCollectionSizeAsync(url, null); } - + /// - public void GetSiteCollectionSizeAsync(string url, object userState) { - if ((this.GetSiteCollectionSizeOperationCompleted == null)) { + public void GetSiteCollectionSizeAsync(string url, object userState) + { + if ((this.GetSiteCollectionSizeOperationCompleted == null)) + { this.GetSiteCollectionSizeOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetSiteCollectionSizeOperationCompleted); } this.InvokeAsync("GetSiteCollectionSize", new object[] { url}, this.GetSiteCollectionSizeOperationCompleted, userState); } - - private void OnGetSiteCollectionSizeOperationCompleted(object arg) { - if ((this.GetSiteCollectionSizeCompleted != null)) { + + private void OnGetSiteCollectionSizeOperationCompleted(object arg) + { + if ((this.GetSiteCollectionSizeCompleted != null)) + { System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); this.GetSiteCollectionSizeCompleted(this, new GetSiteCollectionSizeCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); } } - + /// - public new void CancelAsync(object userState) { + [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/SetPeoplePickerOu", RequestNamespace = "http://smbsaas/websitepanel/server/", ResponseNamespace = "http://smbsaas/websitepanel/server/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public void SetPeoplePickerOu(string site, string ou) + { + this.Invoke("SetPeoplePickerOu", new object[] { + site, + ou}); + } + + /// + public System.IAsyncResult BeginSetPeoplePickerOu(string site, string ou, System.AsyncCallback callback, object asyncState) + { + return this.BeginInvoke("SetPeoplePickerOu", new object[] { + site, + ou}, callback, asyncState); + } + + /// + public void EndSetPeoplePickerOu(System.IAsyncResult asyncResult) + { + this.EndInvoke(asyncResult); + } + + /// + public void SetPeoplePickerOuAsync(string site, string ou) + { + this.SetPeoplePickerOuAsync(site, ou, null); + } + + /// + public void SetPeoplePickerOuAsync(string site, string ou, object userState) + { + if ((this.SetPeoplePickerOuOperationCompleted == null)) + { + this.SetPeoplePickerOuOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSetPeoplePickerOuOperationCompleted); + } + this.InvokeAsync("SetPeoplePickerOu", new object[] { + site, + ou}, this.SetPeoplePickerOuOperationCompleted, userState); + } + + private void OnSetPeoplePickerOuOperationCompleted(object arg) + { + if ((this.SetPeoplePickerOuCompleted != null)) + { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.SetPeoplePickerOuCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// + public new void CancelAsync(object userState) + { base.CancelAsync(userState); } } - - - - - + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] public delegate void GetSupportedLanguagesCompletedEventHandler(object sender, GetSupportedLanguagesCompletedEventArgs e); - + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class GetSupportedLanguagesCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { - + public partial class GetSupportedLanguagesCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs + { + private object[] results; - - internal GetSupportedLanguagesCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : - base(exception, cancelled, userState) { + + internal GetSupportedLanguagesCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) + { this.results = results; } - + /// - public int[] Result { - get { + public int[] Result + { + get + { this.RaiseExceptionIfNecessary(); return ((int[])(this.results[0])); } } } - + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] public delegate void GetSiteCollectionsCompletedEventHandler(object sender, GetSiteCollectionsCompletedEventArgs e); - + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class GetSiteCollectionsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { - + public partial class GetSiteCollectionsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs + { + private object[] results; - - internal GetSiteCollectionsCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : - base(exception, cancelled, userState) { + + internal GetSiteCollectionsCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) + { this.results = results; } - + /// - public SharePointSiteCollection[] Result { - get { + public SharePointSiteCollection[] Result + { + get + { this.RaiseExceptionIfNecessary(); return ((SharePointSiteCollection[])(this.results[0])); } } } - + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] public delegate void GetSiteCollectionCompletedEventHandler(object sender, GetSiteCollectionCompletedEventArgs e); - + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class GetSiteCollectionCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { - + public partial class GetSiteCollectionCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs + { + private object[] results; - - internal GetSiteCollectionCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : - base(exception, cancelled, userState) { + + internal GetSiteCollectionCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) + { this.results = results; } - + /// - public SharePointSiteCollection Result { - get { + public SharePointSiteCollection Result + { + get + { this.RaiseExceptionIfNecessary(); return ((SharePointSiteCollection)(this.results[0])); } } } - + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] public delegate void CreateSiteCollectionCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e); - + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] public delegate void UpdateQuotasCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e); - + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] public delegate void CalculateSiteCollectionsDiskSpaceCompletedEventHandler(object sender, CalculateSiteCollectionsDiskSpaceCompletedEventArgs e); - + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class CalculateSiteCollectionsDiskSpaceCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { - + public partial class CalculateSiteCollectionsDiskSpaceCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs + { + private object[] results; - - internal CalculateSiteCollectionsDiskSpaceCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : - base(exception, cancelled, userState) { + + internal CalculateSiteCollectionsDiskSpaceCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) + { this.results = results; } - + /// - public SharePointSiteDiskSpace[] Result { - get { + public SharePointSiteDiskSpace[] Result + { + get + { this.RaiseExceptionIfNecessary(); return ((SharePointSiteDiskSpace[])(this.results[0])); } } } - + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] public delegate void DeleteSiteCollectionCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e); - + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] public delegate void BackupSiteCollectionCompletedEventHandler(object sender, BackupSiteCollectionCompletedEventArgs e); - + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class BackupSiteCollectionCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { - + public partial class BackupSiteCollectionCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs + { + private object[] results; - - internal BackupSiteCollectionCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : - base(exception, cancelled, userState) { + + internal BackupSiteCollectionCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) + { this.results = results; } - + /// - public string Result { - get { + public string Result + { + get + { this.RaiseExceptionIfNecessary(); return ((string)(this.results[0])); } } } - + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] public delegate void RestoreSiteCollectionCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e); - + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] public delegate void GetTempFileBinaryChunkCompletedEventHandler(object sender, GetTempFileBinaryChunkCompletedEventArgs e); - + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class GetTempFileBinaryChunkCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { - + public partial class GetTempFileBinaryChunkCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs + { + private object[] results; - - internal GetTempFileBinaryChunkCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : - base(exception, cancelled, userState) { + + internal GetTempFileBinaryChunkCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) + { this.results = results; } - + /// - public byte[] Result { - get { + public byte[] Result + { + get + { this.RaiseExceptionIfNecessary(); return ((byte[])(this.results[0])); } } } - + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] public delegate void AppendTempFileBinaryChunkCompletedEventHandler(object sender, AppendTempFileBinaryChunkCompletedEventArgs e); - + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class AppendTempFileBinaryChunkCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { - + public partial class AppendTempFileBinaryChunkCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs + { + private object[] results; - - internal AppendTempFileBinaryChunkCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : - base(exception, cancelled, userState) { + + internal AppendTempFileBinaryChunkCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) + { this.results = results; } - + /// - public string Result { - get { + public string Result + { + get + { this.RaiseExceptionIfNecessary(); return ((string)(this.results[0])); } } } - + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] public delegate void GetSiteCollectionSizeCompletedEventHandler(object sender, GetSiteCollectionSizeCompletedEventArgs e); - + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class GetSiteCollectionSizeCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { - + public partial class GetSiteCollectionSizeCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs + { + private object[] results; - - internal GetSiteCollectionSizeCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : - base(exception, cancelled, userState) { + + internal GetSiteCollectionSizeCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) + { this.results = results; } - + /// - public long Result { - get { + public long Result + { + get + { this.RaiseExceptionIfNecessary(); return ((long)(this.results[0])); } } } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] + public delegate void SetPeoplePickerOuCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e); } diff --git a/WebsitePanel/Sources/WebsitePanel.Server/HostedSharePointServer.asmx.cs b/WebsitePanel/Sources/WebsitePanel.Server/HostedSharePointServer.asmx.cs index a80da75a..ac540abd 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server/HostedSharePointServer.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server/HostedSharePointServer.asmx.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2012, Outercurve Foundation. +// Copyright (c) 2011, Outercurve Foundation. // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, @@ -38,186 +38,185 @@ using Microsoft.Web.Services3; namespace WebsitePanel.Server { - /// - /// Summary description for HostedSharePointServer - /// - [WebService(Namespace = "http://smbsaas/websitepanel/server/")] - [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] - [Policy("ServerPolicy")] - [ToolboxItem(false)] - public class HostedSharePointServer : HostingServiceProviderWebService - { - private delegate TReturn Action(); + /// + /// Summary description for HostedSharePointServer + /// + [WebService(Namespace = "http://smbsaas/websitepanel/server/")] + [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] + [Policy("ServerPolicy")] + [ToolboxItem(false)] + public class HostedSharePointServer : HostingServiceProviderWebService + { + private delegate TReturn Action(); - /// - /// Gets hosted SharePoint provider instance. - /// - private IHostedSharePointServer HostedSharePointServerProvider - { - get { return (IHostedSharePointServer)Provider; } - } + /// + /// Gets hosted SharePoint provider instance. + /// + private IHostedSharePointServer HostedSharePointServerProvider + { + get { return (IHostedSharePointServer)Provider; } + } - /// - /// Gets list of supported languages by this installation of SharePoint. - /// - /// List of supported languages - [WebMethod, SoapHeader("settings")] - public int[] GetSupportedLanguages() - { - return ExecuteAction(delegate - { - return HostedSharePointServerProvider.GetSupportedLanguages(); - }, "GetSupportedLanguages"); - } + /// + /// Gets list of supported languages by this installation of SharePoint. + /// + /// List of supported languages + [WebMethod, SoapHeader("settings")] + public int[] GetSupportedLanguages() + { + return ExecuteAction(delegate + { + return HostedSharePointServerProvider.GetSupportedLanguages(); + }, "GetSupportedLanguages"); + } - /// - /// Gets list of SharePoint collections within root web application. - /// - /// List of SharePoint collections within root web application. - [WebMethod, SoapHeader("settings")] - public SharePointSiteCollection[] GetSiteCollections() - { - return ExecuteAction(delegate - { - return HostedSharePointServerProvider.GetSiteCollections(); - }, "GetSiteCollections"); - } + /// + /// Gets list of SharePoint collections within root web application. + /// + /// List of SharePoint collections within root web application. + [WebMethod, SoapHeader("settings")] + public SharePointSiteCollection[] GetSiteCollections() + { + return ExecuteAction(delegate + { + return HostedSharePointServerProvider.GetSiteCollections(); + }, "GetSiteCollections"); + } - /// - /// Gets SharePoint collection within root web application with given name. - /// - /// Url that uniquely identifies site collection to be loaded. - /// SharePoint collection within root web application with given name. - [WebMethod, SoapHeader("settings")] - public SharePointSiteCollection GetSiteCollection(string url) - { - return ExecuteAction(delegate - { - return HostedSharePointServerProvider.GetSiteCollection(url); - }, "GetSiteCollection"); - } + /// + /// Gets SharePoint collection within root web application with given name. + /// + /// Url that uniquely identifies site collection to be loaded. + /// SharePoint collection within root web application with given name. + [WebMethod, SoapHeader("settings")] + public SharePointSiteCollection GetSiteCollection(string url) + { + return ExecuteAction(delegate + { + return HostedSharePointServerProvider.GetSiteCollection(url); + }, "GetSiteCollection"); + } - /// - /// Creates site collection within predefined root web application. - /// - /// Information about site coolection to be created. - [WebMethod, SoapHeader("settings")] - public void CreateSiteCollection(SharePointSiteCollection siteCollection) - { - siteCollection.OwnerLogin = AttachNetbiosDomainName(siteCollection.OwnerLogin); - ExecuteAction(delegate - { - HostedSharePointServerProvider.CreateSiteCollection(siteCollection); - return new object(); - }, "CreateSiteCollection"); - } + /// + /// Creates site collection within predefined root web application. + /// + /// Information about site coolection to be created. + [WebMethod, SoapHeader("settings")] + public void CreateSiteCollection(SharePointSiteCollection siteCollection) + { + siteCollection.OwnerLogin = AttachNetbiosDomainName(siteCollection.OwnerLogin); + ExecuteAction(delegate + { + HostedSharePointServerProvider.CreateSiteCollection(siteCollection); + return new object(); + }, "CreateSiteCollection"); + } [WebMethod, SoapHeader("settings")] public void UpdateQuotas(string url, long maxSize, long warningSize) { ExecuteAction(delegate - { - HostedSharePointServerProvider.UpdateQuotas(url, maxSize, warningSize); - return new object(); - }, "UpdateQuotas"); - - - + { + HostedSharePointServerProvider.UpdateQuotas(url, maxSize, warningSize); + return new object(); + }, "UpdateQuotas"); + + + } [WebMethod, SoapHeader("settings")] public SharePointSiteDiskSpace[] CalculateSiteCollectionsDiskSpace(string[] urls) { - SharePointSiteDiskSpace []ret = null; + SharePointSiteDiskSpace[] ret = null; ret = ExecuteAction(delegate - { - return HostedSharePointServerProvider.CalculateSiteCollectionsDiskSpace(urls); - }, "CalculateSiteCollectionDiskSpace"); - return ret; + { + return HostedSharePointServerProvider.CalculateSiteCollectionsDiskSpace(urls); + }, "CalculateSiteCollectionDiskSpace"); + return ret; } /// - /// Deletes site collection under given url. - /// - /// Url that uniquely identifies site collection to be deleted. - [WebMethod, SoapHeader("settings")] - public void DeleteSiteCollection(string url) - { - ExecuteAction(delegate - { - HostedSharePointServerProvider.DeleteSiteCollection(url); - return new object(); - }, "DeleteSiteCollection"); - } + /// Deletes site collection under given url. + /// + /// Url that uniquely identifies site collection to be deleted. + [WebMethod, SoapHeader("settings")] + public void DeleteSiteCollection(SharePointSiteCollection siteCollection) + { + ExecuteAction(delegate + { + HostedSharePointServerProvider.DeleteSiteCollection(siteCollection); + return new object(); + }, "DeleteSiteCollection"); + } + /// + /// Backups site collection under give url. + /// + /// Url that uniquely identifies site collection to be deleted. + /// Resulting backup file name. + /// A value which shows whether created backup must be archived. + /// Created backup full path. + [WebMethod, SoapHeader("settings")] + public string BackupSiteCollection(string url, string filename, bool zip) + { + return ExecuteAction(delegate + { + return + HostedSharePointServerProvider.BackupSiteCollection(url, filename, zip); + }, "BackupSiteCollection"); + } - /// - /// Backups site collection under give url. - /// - /// Url that uniquely identifies site collection to be deleted. - /// Resulting backup file name. - /// A value which shows whether created backup must be archived. - /// Created backup full path. - [WebMethod, SoapHeader("settings")] - public string BackupSiteCollection(string url, string filename, bool zip) - { - return ExecuteAction(delegate - { - return - HostedSharePointServerProvider.BackupSiteCollection(url, filename, zip); - }, "BackupSiteCollection"); - } + /// + /// Restores site collection under given url from backup. + /// + /// Site collection to be restored. + /// Backup file name to restore from. + [WebMethod, SoapHeader("settings")] + public void RestoreSiteCollection(SharePointSiteCollection siteCollection, string filename) + { + siteCollection.OwnerLogin = AttachNetbiosDomainName(siteCollection.OwnerLogin); + ExecuteAction(delegate + { + HostedSharePointServerProvider.RestoreSiteCollection(siteCollection, filename); + return new object(); + }, "RestoreSiteCollection"); + } - /// - /// Restores site collection under given url from backup. - /// - /// Site collection to be restored. - /// Backup file name to restore from. - [WebMethod, SoapHeader("settings")] - public void RestoreSiteCollection(SharePointSiteCollection siteCollection, string filename) - { - siteCollection.OwnerLogin = AttachNetbiosDomainName(siteCollection.OwnerLogin); - ExecuteAction(delegate - { - HostedSharePointServerProvider.RestoreSiteCollection(siteCollection, filename); - return new object(); - }, "RestoreSiteCollection"); - } + /// + /// Gets binary data chunk of specified size from specified offset. + /// + /// Path to file to get bunary data chunk from. + /// Offset from which to start data reading. + /// Binary data chunk length. + /// Binary data chunk read from file. + [WebMethod, SoapHeader("settings")] + public byte[] GetTempFileBinaryChunk(string path, int offset, int length) + { + return ExecuteAction(delegate + { + return + HostedSharePointServerProvider.GetTempFileBinaryChunk(path, offset, length); + }, "GetTempFileBinaryChunk"); + } - /// - /// Gets binary data chunk of specified size from specified offset. - /// - /// Path to file to get bunary data chunk from. - /// Offset from which to start data reading. - /// Binary data chunk length. - /// Binary data chunk read from file. - [WebMethod, SoapHeader("settings")] - public byte[] GetTempFileBinaryChunk(string path, int offset, int length) - { - return ExecuteAction(delegate - { - return - HostedSharePointServerProvider.GetTempFileBinaryChunk(path, offset, length); - }, "GetTempFileBinaryChunk"); - } - - /// - /// Appends supplied binary data chunk to file. - /// - /// Non existent file name to append to. - /// Full path to existent file to append to. - /// Binary data chunk to append to. - /// Path to file that was appended with chunk. - [WebMethod, SoapHeader("settings")] - public virtual string AppendTempFileBinaryChunk(string fileName, string path, byte[] chunk) - { - return ExecuteAction(delegate - { - return - HostedSharePointServerProvider.AppendTempFileBinaryChunk(fileName, path, chunk); - }, "AppendTempFileBinaryChunk"); - } + /// + /// Appends supplied binary data chunk to file. + /// + /// Non existent file name to append to. + /// Full path to existent file to append to. + /// Binary data chunk to append to. + /// Path to file that was appended with chunk. + [WebMethod, SoapHeader("settings")] + public virtual string AppendTempFileBinaryChunk(string fileName, string path, byte[] chunk) + { + return ExecuteAction(delegate + { + return + HostedSharePointServerProvider.AppendTempFileBinaryChunk(fileName, path, chunk); + }, "AppendTempFileBinaryChunk"); + } [WebMethod, SoapHeader("settings")] @@ -230,38 +229,46 @@ namespace WebsitePanel.Server }, "GetSiteCollectionSize"); } - /// - /// Executes supplied action and performs logging. - /// - /// Type of action's return value. - /// Action to be executed. - /// Action name for logging purposes. - /// Action execution result. - private TReturn ExecuteAction(Action action, string actionName) - { - try - { - Log.WriteStart("'{0}' {1}", ProviderSettings.ProviderName, actionName); - TReturn result = action(); - Log.WriteEnd("'{0}' {1}", ProviderSettings.ProviderName, actionName); - return result; - } - catch (Exception ex) - { - Log.WriteError(String.Format("Can't {1} '{0}' provider", ProviderSettings.ProviderName, actionName), ex); - throw; - } - } - /// - /// Returns fully qualified netbios account name. - /// - /// Account name. - /// Fully qualified netbios account name. - private string AttachNetbiosDomainName(string accountName) - { - string domainNetbiosName = String.Format("{0}\\", ActiveDirectoryUtils.GetNETBIOSDomainName(ServerSettings.ADRootDomain)); - return String.Format("{0}{1}", domainNetbiosName, accountName.Replace(domainNetbiosName, String.Empty)); - } - } + [WebMethod, SoapHeader("settings")] + public void SetPeoplePickerOu(string site, string ou) + { + HostedSharePointServerProvider.SetPeoplePickerOu(site, ou); + } + + + /// + /// Executes supplied action and performs logging. + /// + /// Type of action's return value. + /// Action to be executed. + /// Action name for logging purposes. + /// Action execution result. + private TReturn ExecuteAction(Action action, string actionName) + { + try + { + Log.WriteStart("'{0}' {1}", ProviderSettings.ProviderName, actionName); + TReturn result = action(); + Log.WriteEnd("'{0}' {1}", ProviderSettings.ProviderName, actionName); + return result; + } + catch (Exception ex) + { + Log.WriteError(String.Format("Can't {1} '{0}' provider", ProviderSettings.ProviderName, actionName), ex); + throw; + } + } + + /// + /// Returns fully qualified netbios account name. + /// + /// Account name. + /// Fully qualified netbios account name. + private string AttachNetbiosDomainName(string accountName) + { + string domainNetbiosName = String.Format("{0}\\", ActiveDirectoryUtils.GetNETBIOSDomainName(ServerSettings.ADRootDomain)); + return String.Format("{0}{1}", domainNetbiosName, accountName.Replace(domainNetbiosName, String.Empty)); + } + } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsSelectDomainControl.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsSelectDomainControl.ascx.cs index 04e842ef..ef0b17eb 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsSelectDomainControl.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsSelectDomainControl.ascx.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2012, Outercurve Foundation. +// Copyright (c) 2011, Outercurve Foundation. // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, @@ -95,6 +95,7 @@ namespace WebsitePanel.Portal { BindDomains(); } + } private void BindDomains() diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/UserSelector.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/UserSelector.ascx index 341e5b7c..1abeb777 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/UserSelector.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/UserSelector.ascx @@ -49,7 +49,7 @@ diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/UserSelector.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/UserSelector.ascx.cs index fe09e266..e27af284 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/UserSelector.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/UserSelector.ascx.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2012, Outercurve Foundation. +// Copyright (c) 2010, SMB SAAS Systems Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, @@ -11,7 +11,7 @@ // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // -// - Neither the name of the Outercurve Foundation nor the names of its +// - Neither the name of the SMB SAAS Systems Inc. nor the names of its // contributors may be used to endorse or promote products derived from this // software without specific prior written permission. // @@ -50,21 +50,82 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls ViewState["IncludeMailboxes"] = value; } } - + + public bool IncludeMailboxesOnly + { + get + { + object ret = ViewState["IncludeMailboxesOnly"]; + return (ret != null) ? (bool)ret : false; + } + set + { + ViewState["IncludeMailboxesOnly"] = value; + } + } + + + public bool ExcludeOCSUsers + { + get + { + object ret = ViewState["ExcludeOCSUsers"]; + return (ret != null) ? (bool)ret : false; + } + set + { + ViewState["ExcludeOCSUsers"] = value; + } + } + + public bool ExcludeLyncUsers + { + get + { + object ret = ViewState["ExcludeLyncUsers"]; + return (ret != null) ? (bool)ret : false; + } + set + { + ViewState["ExcludeLyncUsers"] = value; + } + } + + + public bool ExcludeBESUsers + { + get + { + object ret = ViewState["ExcludeBESUsers"]; + return (ret != null) ? (bool)ret : false; + } + set + { + ViewState["ExcludeBESUsers"] = value; + } + } + + public int ExcludeAccountId - { - get { return PanelRequest.AccountID; } - } + { + get { return PanelRequest.AccountID; } + } - public void SetAccount(OrganizationUser account) - { - BindSelectedAccount(account); - } + public void SetAccount(OrganizationUser account) + { + BindSelectedAccount(account); + } + + public string GetAccount() + { + return (string)ViewState["AccountName"]; + } + + public string GetSAMAccountName() + { + return (string)ViewState["SAMAccountName"]; + } - public string GetAccount() - { - return (string)ViewState["AccountName"]; - } public string GetDisplayName() { @@ -77,56 +138,93 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls } public int GetAccountId() - { - return Utils.ParseInt(ViewState["AccountId"], 0); + { + return Utils.ParseInt(ViewState["AccountId"], 0); } protected void Page_Load(object sender, EventArgs e) { - + } - private void BindSelectedAccount(OrganizationUser account) - { - if (account != null) - { - txtDisplayName.Text = account.DisplayName; + private void BindSelectedAccount(OrganizationUser account) + { + if (account != null) + { + txtDisplayName.Text = account.DisplayName; ViewState["AccountName"] = account.AccountName; ViewState["DisplayName"] = account.DisplayName; ViewState["PrimaryEmailAddress"] = account.PrimaryEmailAddress; - ViewState["AccountId"] = account.AccountId; - } - else - { - txtDisplayName.Text = ""; - ViewState["AccountName"] = null; + ViewState["AccountId"] = account.AccountId; + ViewState["SAMAccountName"] = account.SamAccountName; + } + else + { + txtDisplayName.Text = ""; + ViewState["AccountName"] = null; ViewState["DisplayName"] = null; ViewState["PrimaryEmailAddress"] = null; - ViewState["AccountId"] = null; - + ViewState["AccountId"] = null; + ViewState["SAMAccountName"] = null; + } - } + } - public string GetAccountImage() - { + public string GetAccountImage() + { return GetThemedImage("Exchange/admin_16.png"); - } + } - private void BindPopupAccounts() - { - OrganizationUser[] accounts = ES.Services.Organizations.SearchAccounts(PanelRequest.ItemID, - ddlSearchColumn.SelectedValue, txtSearchValue.Text + "%", "", IncludeMailboxes); + private void BindPopupAccounts() + { + OrganizationUser[] accounts = ES.Services.Organizations.SearchAccounts(PanelRequest.ItemID, + ddlSearchColumn.SelectedValue, txtSearchValue.Text + "%", "", IncludeMailboxes); - if (ExcludeAccountId > 0) - { - List updatedAccounts = new List(); - foreach (OrganizationUser account in accounts) - if (account.AccountId != ExcludeAccountId) - updatedAccounts.Add(account); + if (ExcludeAccountId > 0) + { + List updatedAccounts = new List(); + foreach (OrganizationUser account in accounts) + if (account.AccountId != ExcludeAccountId) + updatedAccounts.Add(account); + + accounts = updatedAccounts.ToArray(); + } + + if (IncludeMailboxesOnly) + { + + List updatedAccounts = new List(); + foreach (OrganizationUser account in accounts) + { + bool addUser = false; + if (account.ExternalEmail != string.Empty) addUser = true; + if ((account.IsBlackBerryUser) & (ExcludeBESUsers)) addUser = false; + if ((account.IsLyncUser) & (ExcludeLyncUsers)) addUser = false; + + if (addUser) updatedAccounts.Add(account); + } + + accounts = updatedAccounts.ToArray(); + } + else + if ((ExcludeOCSUsers) | (ExcludeBESUsers) | (ExcludeLyncUsers)) + { + + List updatedAccounts = new List(); + foreach (OrganizationUser account in accounts) + { + bool addUser = true; + if ((account.IsOCSUser) & (ExcludeOCSUsers)) addUser = false; + if ((account.IsLyncUser) & (ExcludeLyncUsers)) addUser = false; + if ((account.IsBlackBerryUser) & (ExcludeBESUsers)) addUser = false; + + if (addUser) updatedAccounts.Add(account); + } + + accounts = updatedAccounts.ToArray(); + } - accounts = updatedAccounts.ToArray(); - } Array.Sort(accounts, CompareAccount); if (Direction == SortDirection.Ascending) @@ -136,15 +234,15 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls } else Direction = SortDirection.Ascending; - + gvPopupAccounts.DataSource = accounts; - gvPopupAccounts.DataBind(); - } + gvPopupAccounts.DataBind(); + } private SortDirection Direction { get { return ViewState[DirectionString] == null ? SortDirection.Descending : (SortDirection)ViewState[DirectionString]; } - set {ViewState[DirectionString] = value;} + set { ViewState[DirectionString] = value; } } private static int CompareAccount(OrganizationUser user1, OrganizationUser user2) @@ -152,57 +250,58 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls return string.Compare(user1.DisplayName, user2.DisplayName); } - - protected void chkIncludeMailboxes_CheckedChanged(object sender, EventArgs e) - { - BindPopupAccounts(); - } - protected void cmdSearch_Click(object sender, ImageClickEventArgs e) - { - BindPopupAccounts(); - } + protected void chkIncludeMailboxes_CheckedChanged(object sender, EventArgs e) + { + BindPopupAccounts(); + } - protected void cmdClear_Click(object sender, EventArgs e) - { - BindSelectedAccount(null); - } + protected void cmdSearch_Click(object sender, ImageClickEventArgs e) + { + BindPopupAccounts(); + } - protected void ImageButton1_Click(object sender, ImageClickEventArgs e) - { - // bind all accounts - BindPopupAccounts(); + protected void cmdClear_Click(object sender, EventArgs e) + { + BindSelectedAccount(null); + } - // show modal - SelectAccountsModal.Show(); - } + protected void ImageButton1_Click(object sender, ImageClickEventArgs e) + { + // bind all accounts + BindPopupAccounts(); - protected void gvPopupAccounts_RowCommand(object sender, GridViewCommandEventArgs e) - { - if (e.CommandName == "SelectAccount") - { - string[] parts = e.CommandArgument.ToString().Split('|'); - OrganizationUser account = new OrganizationUser(); - account.AccountName = parts[0]; - account.DisplayName = parts[1]; - account.PrimaryEmailAddress = parts[2]; - account.AccountId = Utils.ParseInt(parts[3]); + // show modal + SelectAccountsModal.Show(); + } - // set account - BindSelectedAccount(account); + protected void gvPopupAccounts_RowCommand(object sender, GridViewCommandEventArgs e) + { + if (e.CommandName == "SelectAccount") + { + string[] parts = e.CommandArgument.ToString().Split('|'); + OrganizationUser account = new OrganizationUser(); + account.AccountName = parts[0]; + account.DisplayName = parts[1]; + account.PrimaryEmailAddress = parts[2]; + account.AccountId = Utils.ParseInt(parts[3]); + account.SamAccountName = parts[4]; - // hide popup - SelectAccountsModal.Hide(); + // set account + BindSelectedAccount(account); - // update parent panel - MainUpdatePanel.Update(); - } - } + // hide popup + SelectAccountsModal.Hide(); + + // update parent panel + MainUpdatePanel.Update(); + } + } protected void OnSorting(object sender, GridViewSortEventArgs e) { - + BindPopupAccounts(); } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/UserSelector.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/UserSelector.ascx.designer.cs index 68fe956e..4775df9a 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/UserSelector.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/UserSelector.ascx.designer.cs @@ -1,10 +1,9 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.4927 // // Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// the code is regenerated. // //------------------------------------------------------------------------------ diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/HostedSharePointEditSiteCollection.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/HostedSharePointEditSiteCollection.ascx index d6bd3c4f..08fa5b5b 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/HostedSharePointEditSiteCollection.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/HostedSharePointEditSiteCollection.ascx @@ -1,25 +1,18 @@ -<%@ Control Language="C#" AutoEventWireup="true" Codebehind="HostedSharePointEditSiteCollection.ascx.cs" - Inherits="WebsitePanel.Portal.HostedSharePointEditSiteCollection" %> +<%@ Control Language="C#" AutoEventWireup="true" Codebehind="HostedSharePointEditSiteCollection.ascx.cs" Inherits="WebsitePanel.Portal.HostedSharePointEditSiteCollection" %> <%@ Register Src="ExchangeServer/UserControls/SizeBox.ascx" TagName="SizeBox" TagPrefix="wsp" %> -<%@ Register Src="UserControls/SimpleMessageBox.ascx" TagName="SimpleMessageBox" - TagPrefix="wsp" %> -<%@ Register TagPrefix="wsp" TagName="CollapsiblePanel" Src="UserControls/CollapsiblePanel.ascx" %> +<%@ Register Src="UserControls/SimpleMessageBox.ascx" TagName="SimpleMessageBox" TagPrefix="wsp" %> +<%@ Register Src="UserControls/CollapsiblePanel.ascx" TagName="CollapsiblePanel" TagPrefix="wsp" %> <%@ Register Src="UserControls/PopupHeader.ascx" TagName="PopupHeader" TagPrefix="wsp" %> <%@ Register Src="ExchangeServer/UserControls/Menu.ascx" TagName="Menu" TagPrefix="wsp" %> -<%@ Register Src="ExchangeServer/UserControls/Breadcrumb.ascx" TagName="Breadcrumb" - TagPrefix="wsp" %> -<%@ Register Src="ExchangeServer/UserControls/DomainSelector.ascx" TagName="DomainSelector" TagPrefix="wsp" %> +<%@ Register Src="ExchangeServer/UserControls/Breadcrumb.ascx" TagName="Breadcrumb" TagPrefix="wsp" %> +<%@ Register Src="UserControls/AllocatePackageIPAddresses.ascx" TagName="SiteUrlBuilder" TagPrefix="wsp" %> <%@ Register Src="ExchangeServer/UserControls/UserSelector.ascx" TagName="UserSelector" TagPrefix="wsp" %> - - -<%@ Register Src="UserControls/EnableAsyncTasksSupport.ascx" TagName="EnableAsyncTasksSupport" - TagPrefix="wsp" %> - +<%@ Register Src="UserControls/EnableAsyncTasksSupport.ascx" TagName="EnableAsyncTasksSupport" TagPrefix="wsp" %> <%@ Register src="UserControls/QuotaEditor.ascx" tagname="QuotaEditor" tagprefix="uc1" %> +<%@ Register Src="DomainsSelectDomainControl.ascx" TagName="DomainsSelectDomainControl" TagPrefix="uc1" %> -
@@ -39,13 +32,18 @@ - + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/HostedSharePointEditSiteCollection.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/HostedSharePointEditSiteCollection.ascx.cs index 79650ced..1c13ab54 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/HostedSharePointEditSiteCollection.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/HostedSharePointEditSiteCollection.ascx.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2012, Outercurve Foundation. +// Copyright (c) 2011, Outercurve Foundation. // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, @@ -35,331 +35,378 @@ using WebsitePanel.Providers.DNS; using WebsitePanel.Providers.HostedSolution; using WebsitePanel.Providers.SharePoint; + namespace WebsitePanel.Portal { - public partial class HostedSharePointEditSiteCollection : WebsitePanelModuleBase - { - SharePointSiteCollection item = null; + public partial class HostedSharePointEditSiteCollection : WebsitePanelModuleBase + { + SharePointSiteCollection item = null; - private int OrganizationId - { - get - { - return PanelRequest.GetInt("ItemID"); - } - } + private int OrganizationId + { + get + { + return PanelRequest.GetInt("ItemID"); + } + } - private int SiteCollectionId - { - get - { - return PanelRequest.GetInt("SiteCollectionID"); - } - } + private int SiteCollectionId + { + get + { + return PanelRequest.GetInt("SiteCollectionID"); + } + } + + protected void Page_Load(object sender, EventArgs e) + { + domain.PackageId = PanelSecurity.PackageId; - protected void Page_Load(object sender, EventArgs e) - { warningStorage.UnlimitedText = GetLocalizedString("WarningUnlimitedValue"); editWarningStorage.UnlimitedText = GetLocalizedString("WarningUnlimitedValue"); - + bool newItem = (this.SiteCollectionId == 0); - tblEditItem.Visible = newItem; - tblViewItem.Visible = !newItem; + tblEditItem.Visible = newItem; + tblViewItem.Visible = !newItem; - //btnUpdate.Visible = newItem; - btnDelete.Visible = !newItem; - btnUpdate.Text = newItem ? GetLocalizedString("Text.Add") : GetLocalizedString("Text.Update"); + //btnUpdate.Visible = newItem; + btnDelete.Visible = !newItem; + btnUpdate.Text = newItem ? GetLocalizedString("Text.Add") : GetLocalizedString("Text.Update"); btnUpdate.OnClientClick = newItem ? GetLocalizedString("btnCreate.OnClientClick") : GetLocalizedString("btnUpdate.OnClientClick"); - btnBackup.Enabled = btnRestore.Enabled = !newItem; + btnBackup.Enabled = btnRestore.Enabled = !newItem; - // bind item - BindItem(); + // bind item + BindItem(); - //this.RegisterOwnerSelector(); - - } + } - private void BindItem() - { - try - { - if (!IsPostBack) - { - if (!this.IsDnsServiceAvailable()) - { - localMessageBox.ShowWarningMessage("HOSTEDSHAREPOINT_NO_DNS"); - } + private void BindItem() + { + try + { + if (!IsPostBack) + { + if (!this.IsDnsServiceAvailable()) + { + localMessageBox.ShowWarningMessage("HOSTEDSHAREPOINT_NO_DNS"); + } - // load item if required - if (this.SiteCollectionId > 0) - { - // existing item - item = ES.Services.HostedSharePointServers.GetSiteCollection(this.SiteCollectionId); - if (item != null) - { - // save package info - ViewState["PackageId"] = item.PackageId; - } - else - RedirectToBrowsePage(); - } - else - { - // new item - ViewState["PackageId"] = PanelSecurity.PackageId; - } - - //this.gvUsers.DataBind(); - - List cultures = new List(); - foreach (int localeId in ES.Services.HostedSharePointServers.GetSupportedLanguages(PanelSecurity.PackageId)) - { - cultures.Add(new CultureInfo(localeId, false)); - } - - this.ddlLocaleID.DataSource = cultures; - this.ddlLocaleID.DataBind(); - } - - if (!IsPostBack) - { - // bind item to controls - if (item != null) - { - // bind item to controls - lnkUrl.Text = item.PhysicalAddress; - lnkUrl.NavigateUrl = item.PhysicalAddress; - litSiteCollectionOwner.Text = String.Format("{0} ({1})", item.OwnerName, item.OwnerEmail); - litLocaleID.Text = new CultureInfo(item.LocaleId, false).DisplayName; - litTitle.Text = item.Title; - litDescription.Text = item.Description; - editWarningStorage.QuotaValue = (int)item.WarningStorage; - editMaxStorage.QuotaValue = (int)item.MaxSiteStorage; - } - - Organization org = ES.Services.Organizations.GetOrganization(OrganizationId); - if (org != null) + // load item if required + if (this.SiteCollectionId > 0) + { + // existing item + item = ES.Services.HostedSharePointServers.GetSiteCollection(this.SiteCollectionId); + if (item != null) { - maxStorage.ParentQuotaValue = org.MaxSharePointStorage; - maxStorage.QuotaValue = org.MaxSharePointStorage; - - editMaxStorage.ParentQuotaValue = org.MaxSharePointStorage; - - - - warningStorage.ParentQuotaValue = org.WarningSharePointStorage; - warningStorage.QuotaValue = org.WarningSharePointStorage; - editWarningStorage.ParentQuotaValue = org.WarningSharePointStorage; + // save package info + ViewState["PackageId"] = item.PackageId; } - - } - OrganizationDomainName[] domains = ES.Services.Organizations.GetOrganizationDomains(PanelRequest.ItemID); + else + RedirectToBrowsePage(); + } + else + { + // new item + ViewState["PackageId"] = PanelSecurity.PackageId; + if (UseSharedSLL(PanelSecurity.PackageId)) + { + + rowUrl.Visible = false; + valRequireHostName.Enabled = false; + valRequireCorrectHostName.Enabled = false; + } + } + + //this.gvUsers.DataBind(); + + List cultures = new List(); + foreach (int localeId in ES.Services.HostedSharePointServers.GetSupportedLanguages(PanelSecurity.PackageId)) + { + cultures.Add(new CultureInfo(localeId, false)); + } + + this.ddlLocaleID.DataSource = cultures; + this.ddlLocaleID.DataBind(); + } + + if (!IsPostBack) + { + // bind item to controls + if (item != null) + { + // bind item to controls + lnkUrl.Text = item.PhysicalAddress; + lnkUrl.NavigateUrl = item.PhysicalAddress; + litSiteCollectionOwner.Text = String.Format("{0} ({1})", item.OwnerName, item.OwnerEmail); + litLocaleID.Text = new CultureInfo(item.LocaleId, false).DisplayName; + litTitle.Text = item.Title; + litDescription.Text = item.Description; + editWarningStorage.QuotaValue = (int)item.WarningStorage; + editMaxStorage.QuotaValue = (int)item.MaxSiteStorage; + } + + Organization org = ES.Services.Organizations.GetOrganization(OrganizationId); + if (org != null) + { + maxStorage.ParentQuotaValue = org.MaxSharePointStorage; + maxStorage.QuotaValue = org.MaxSharePointStorage; + + editMaxStorage.ParentQuotaValue = org.MaxSharePointStorage; + + + + warningStorage.ParentQuotaValue = org.WarningSharePointStorage; + warningStorage.QuotaValue = org.WarningSharePointStorage; + editWarningStorage.ParentQuotaValue = org.WarningSharePointStorage; + } + + } + //OrganizationDomainName[] domains = ES.Services.Organizations.GetOrganizationDomains(PanelRequest.ItemID); + + //DomainInfo[] domains = ES.Services.Servers.GetMyDomains(PanelSecurity.PackageId); + + EnterpriseServer.DomainInfo[] domains = ES.Services.Servers.GetDomains(PanelSecurity.PackageId); + + if (domains.Length == 0) + { + localMessageBox.ShowWarningMessage("HOSTEDSHAREPOINT_NO_DOMAINS"); + DisableFormControls(this, btnCancel); + return; + } + //if (this.gvUsers.Rows.Count == 0) + //{ + // localMessageBox.ShowWarningMessage("HOSTEDSHAREPOINT_NO_USERS"); + // DisableFormControls(this, btnCancel); + // return; + //} + } + catch + { - if (domains.Length == 0) - { - localMessageBox.ShowWarningMessage("HOSTEDSHAREPOINT_NO_DOMAINS"); - DisableFormControls(this, btnCancel); - return; - } - //if (this.gvUsers.Rows.Count == 0) - //{ - // localMessageBox.ShowWarningMessage("HOSTEDSHAREPOINT_NO_USERS"); - // DisableFormControls(this, btnCancel); - // return; - //} - } - catch - { - localMessageBox.ShowWarningMessage("INIT_SERVICE_ITEM_FORM"); - - DisableFormControls(this, btnCancel); - return; - } - } - private void SaveItem() - { - if (!Page.IsValid) - { - return; - } + DisableFormControls(this, btnCancel); + return; + } + } - - if (this.SiteCollectionId == 0) - { + private void SaveItem() + { + if (!Page.IsValid) + { + return; + } + + + if (this.SiteCollectionId == 0) + { if (this.userSelector.GetAccount() == null) { localMessageBox.ShowWarningMessage("HOSTEDSHAREPOINT_NO_USERS"); return; } - + // new item - try - { - SharePointSiteCollectionListPaged existentSiteCollections = ES.Services.HostedSharePointServers.GetSiteCollectionsPaged(PanelSecurity.PackageId, this.OrganizationId, "ItemName", String.Format("%{0}", this.domain.DomainName), String.Empty, 0, Int32.MaxValue); - foreach (SharePointSiteCollection existentSiteCollection in existentSiteCollections.SiteCollections) - { - Uri existentSiteCollectionUri = new Uri(existentSiteCollection.Name); - if (existentSiteCollection.Name == String.Format("{0}://{1}", existentSiteCollectionUri.Scheme, this.domain.DomainName)) - { - localMessageBox.ShowWarningMessage("HOSTEDSHAREPOINT_DOMAIN_IN_USE"); - return; - } - } + try + { + item = new SharePointSiteCollection(); + + if (!UseSharedSLL(PanelSecurity.PackageId)) + { + SharePointSiteCollectionListPaged existentSiteCollections = ES.Services.HostedSharePointServers.GetSiteCollectionsPaged(PanelSecurity.PackageId, this.OrganizationId, "ItemName", String.Format("%{0}", this.domain.DomainName), String.Empty, 0, Int32.MaxValue); + foreach (SharePointSiteCollection existentSiteCollection in existentSiteCollections.SiteCollections) + { + Uri existentSiteCollectionUri = new Uri(existentSiteCollection.Name); + if (existentSiteCollection.Name == String.Format("{0}://{1}", existentSiteCollectionUri.Scheme, this.txtHostName.Text.ToLower() + "." + this.domain.DomainName)) + { + localMessageBox.ShowWarningMessage("HOSTEDSHAREPOINT_DOMAIN_IN_USE"); + return; + } + } + + item.Name = this.txtHostName.Text.ToLower() + "." + this.domain.DomainName; + } + else + item.Name = string.Empty; + + // get form data + + item.OrganizationId = this.OrganizationId; + item.Id = this.SiteCollectionId; + item.PackageId = PanelSecurity.PackageId; + + item.LocaleId = Int32.Parse(this.ddlLocaleID.SelectedValue); + item.OwnerLogin = this.userSelector.GetSAMAccountName(); + item.OwnerEmail = this.userSelector.GetPrimaryEmailAddress(); + item.OwnerName = this.userSelector.GetDisplayName(); + item.Title = txtTitle.Text; + item.Description = txtDescription.Text; + - // get form data - item = new SharePointSiteCollection(); - item.OrganizationId = this.OrganizationId; - item.Id = this.SiteCollectionId; - item.PackageId = PanelSecurity.PackageId; - item.Name = this.domain.DomainName; - item.LocaleId = Int32.Parse(this.ddlLocaleID.SelectedValue); - item.OwnerLogin = this.userSelector.GetAccount(); - item.OwnerEmail = this.userSelector.GetPrimaryEmailAddress(); - item.OwnerName = this.userSelector.GetDisplayName(); - item.Title = txtTitle.Text; - item.Description = txtDescription.Text; - - item.MaxSiteStorage = maxStorage.QuotaValue; - item.WarningStorage = warningStorage.QuotaValue; + item.WarningStorage = warningStorage.QuotaValue; - int result = ES.Services.HostedSharePointServers.AddSiteCollection(item); - if (result < 0) - { - localMessageBox.ShowResultMessage(result); - return; - } - } - catch (Exception ex) - { - localMessageBox.ShowErrorMessage("HOSTEDSHAREPOINT_ADD_SITECOLLECTION", ex); - return; - } - } + int result = ES.Services.HostedSharePointServers.AddSiteCollection(item); + if (result < 0) + { + localMessageBox.ShowResultMessage(result); + return; + } + } + catch (Exception ex) + { + localMessageBox.ShowErrorMessage("HOSTEDSHAREPOINT_ADD_SITECOLLECTION", ex); + return; + } + } else - { - ES.Services.HostedSharePointServers.UpdateQuota(PanelRequest.ItemID, SiteCollectionId, editMaxStorage.QuotaValue, editWarningStorage.QuotaValue); - } + { + ES.Services.HostedSharePointServers.UpdateQuota(PanelRequest.ItemID, SiteCollectionId, editMaxStorage.QuotaValue, editWarningStorage.QuotaValue); + } - // return - RedirectToSiteCollectionsList(); - } + // return + RedirectToSiteCollectionsList(); + } - private void AddDnsRecord(int domainId, string recordName, string recordData) - { - int result = ES.Services.Servers.AddDnsZoneRecord(domainId, recordName, DnsRecordType.A, recordData, 0); - if (result < 0) - { - ShowResultMessage(result); - } - } + private void AddDnsRecord(int domainId, string recordName, string recordData) + { + int result = ES.Services.Servers.AddDnsZoneRecord(domainId, recordName, DnsRecordType.A, recordData, 0); + if (result < 0) + { + ShowResultMessage(result); + } + } - private bool IsDnsServiceAvailable() - { - ProviderInfo dnsProvider = ES.Services.Servers.GetPackageServiceProvider(PanelSecurity.PackageId, ResourceGroups.Dns); - return dnsProvider != null; - } + private bool IsDnsServiceAvailable() + { + ProviderInfo dnsProvider = ES.Services.Servers.GetPackageServiceProvider(PanelSecurity.PackageId, ResourceGroups.Dns); + return dnsProvider != null; + } - private void DeleteItem() - { - // delete - try - { - int result = ES.Services.HostedSharePointServers.DeleteSiteCollection(this.SiteCollectionId); - if (result < 0) - { - ShowResultMessage(result); - return; - } - } - catch (Exception ex) - { - localMessageBox.ShowErrorMessage("HOSTEDSHAREPOINT_DELETE_SITECOLLECTION", ex); - return; - } + private void DeleteItem() + { + // delete + try + { + int result = ES.Services.HostedSharePointServers.DeleteSiteCollection(this.SiteCollectionId); + if (result < 0) + { + ShowResultMessage(result); + return; + } + } + catch (Exception ex) + { + localMessageBox.ShowErrorMessage("HOSTEDSHAREPOINT_DELETE_SITECOLLECTION", ex); + return; + } - // return - RedirectToSiteCollectionsList(); - } + // return + RedirectToSiteCollectionsList(); + } - protected void odsAccountsPaged_Selected(object sender, ObjectDataSourceStatusEventArgs e) - { - if (e.Exception != null) - { - localMessageBox.ShowErrorMessage("ORGANIZATION_GET_USERS", e.Exception); - e.ExceptionHandled = true; - } - } + protected void odsAccountsPaged_Selected(object sender, ObjectDataSourceStatusEventArgs e) + { + if (e.Exception != null) + { + localMessageBox.ShowErrorMessage("ORGANIZATION_GET_USERS", e.Exception); + e.ExceptionHandled = true; + } + } - protected void btnCancel_Click(object sender, EventArgs e) - { - // return - RedirectToSiteCollectionsList(); - } + protected void btnCancel_Click(object sender, EventArgs e) + { + // return + RedirectToSiteCollectionsList(); + } - protected void btnDelete_Click(object sender, EventArgs e) - { - DeleteItem(); - } + protected void btnDelete_Click(object sender, EventArgs e) + { + DeleteItem(); + } - protected void btnUpdate_Click(object sender, EventArgs e) - { - SaveItem(); - } - protected void btnBackup_Click(object sender, EventArgs e) - { - Response.Redirect(EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "sharepoint_backup_sitecollection", "SiteCollectionID=" + this.SiteCollectionId,"ItemID=" + PanelRequest.ItemID.ToString())); - } + protected void btnUpdate_Click(object sender, EventArgs e) + { + SaveItem(); + } - protected void btnRestore_Click(object sender, EventArgs e) - { - Response.Redirect(EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "sharepoint_restore_sitecollection", "SiteCollectionID=" + this.SiteCollectionId, "ItemID=" + PanelRequest.ItemID.ToString())); - } + protected void btnBackup_Click(object sender, EventArgs e) + { + Response.Redirect(EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "sharepoint_backup_sitecollection", "SiteCollectionID=" + this.SiteCollectionId, "ItemID=" + PanelRequest.ItemID.ToString())); + } + + protected void btnRestore_Click(object sender, EventArgs e) + { + Response.Redirect(EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "sharepoint_restore_sitecollection", "SiteCollectionID=" + this.SiteCollectionId, "ItemID=" + PanelRequest.ItemID.ToString())); + } - private void RedirectToSiteCollectionsList() - { - Response.Redirect(EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "sharepoint_sitecollections", "ItemID=" + PanelRequest.ItemID.ToString())); - } - //private void RegisterOwnerSelector() - //{ - // // Define the name and type of the client scripts on the page. - // String csname = "OwnerSelectorScript"; - // Type cstype = this.GetType(); + private void RedirectToSiteCollectionsList() + { + Response.Redirect(EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "sharepoint_sitecollections", "ItemID=" + PanelRequest.ItemID.ToString())); + } - // // Get a ClientScriptManager reference from the Page class. - // ClientScriptManager cs = Page.ClientScript; + private bool UseSharedSLL(int packageID) + { + PackageContext cntx = ES.Services.Packages.GetPackageContext(PanelSecurity.PackageId); + if (cntx != null) + { + foreach (QuotaValueInfo quota in cntx.QuotasArray) + { + switch (quota.QuotaId) + { + case 400: + if (Convert.ToBoolean(quota.QuotaAllocatedValue)) + { + return true; + } - // // Check to see if the client script is already registered. - // if (!cs.IsClientScriptBlockRegistered(cstype, csname)) - // { - // StringBuilder ownerSelector = new StringBuilder(); - // ownerSelector.Append(""); - // cs.RegisterClientScriptBlock(cstype, csname, ownerSelector.ToString(), false); - // } + break; + } + } + } - //} + return false; + } - //private StringDictionary ConvertArrayToDictionary(string[] settings) - //{ - // StringDictionary r = new StringDictionary(); - // foreach (string setting in settings) - // { - // int idx = setting.IndexOf('='); - // r.Add(setting.Substring(0, idx), setting.Substring(idx + 1)); - // } - // return r; - //} - } + + //private void RegisterOwnerSelector() + //{ + // // Define the name and type of the client scripts on the page. + // String csname = "OwnerSelectorScript"; + // Type cstype = this.GetType(); + + // // Get a ClientScriptManager reference from the Page class. + // ClientScriptManager cs = Page.ClientScript; + + // // Check to see if the client script is already registered. + // if (!cs.IsClientScriptBlockRegistered(cstype, csname)) + // { + // StringBuilder ownerSelector = new StringBuilder(); + // ownerSelector.Append(""); + // cs.RegisterClientScriptBlock(cstype, csname, ownerSelector.ToString(), false); + // } + + //} + + //private StringDictionary ConvertArrayToDictionary(string[] settings) + //{ + // StringDictionary r = new StringDictionary(); + // foreach (string setting in settings) + // { + // int idx = setting.IndexOf('='); + // r.Add(setting.Substring(0, idx), setting.Substring(idx + 1)); + // } + // return r; + //} + } } \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/HostedSharePointEditSiteCollection.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/HostedSharePointEditSiteCollection.ascx.designer.cs index 995d27cd..f5979ef6 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/HostedSharePointEditSiteCollection.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/HostedSharePointEditSiteCollection.ascx.designer.cs @@ -1,10 +1,9 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.1433 // // Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// the code is regenerated. // //------------------------------------------------------------------------------ @@ -76,6 +75,15 @@ namespace WebsitePanel.Portal { /// protected global::System.Web.UI.HtmlControls.HtmlTable tblEditItem; + /// + /// rowUrl control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlTableRow rowUrl; + /// /// lblSiteCollectionUrl control. /// @@ -85,6 +93,15 @@ namespace WebsitePanel.Portal { /// protected global::System.Web.UI.WebControls.Label lblSiteCollectionUrl; + /// + /// txtHostName control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtHostName; + /// /// domain control. /// @@ -92,7 +109,25 @@ namespace WebsitePanel.Portal { /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::WebsitePanel.Portal.ExchangeServer.UserControls.DomainSelector domain; + protected global::WebsitePanel.Portal.DomainsSelectDomainControl domain; + + /// + /// valRequireHostName control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator valRequireHostName; + + /// + /// valRequireCorrectHostName control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RegularExpressionValidator valRequireCorrectHostName; /// /// lblSiteCollectionOwner control. diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/App_LocalResources/HostedSharePoint30_Settings.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/App_LocalResources/HostedSharePoint30_Settings.ascx.resx index 96bcb25c..39e1c0a4 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/App_LocalResources/HostedSharePoint30_Settings.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/App_LocalResources/HostedSharePoint30_Settings.ascx.resx @@ -112,11 +112,14 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Provision local hosts file + SharePoint Backup Temporary Folder: @@ -126,9 +129,15 @@ SharePoint Web Application IP: + + Shared SSL Root: + SharePoint Backup + + Wildcard Certificate Root + Please note that WebsitePanel Server account should have access to this folder. Leave this field blank to use default path. diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/HostedSharePoint30_Settings.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/HostedSharePoint30_Settings.ascx index b4d4e827..fcfbee86 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/HostedSharePoint30_Settings.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/HostedSharePoint30_Settings.ascx @@ -17,7 +17,21 @@ - + + + + + + + + +
- + . + +
+ +
+ + + +
@@ -39,4 +53,5 @@
+
\ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/HostedSharePoint30_Settings.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/HostedSharePoint30_Settings.ascx.cs index 518b23ef..7b1fd2f5 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/HostedSharePoint30_Settings.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/HostedSharePoint30_Settings.ascx.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2012, Outercurve Foundation. +// Copyright (c) 2011, Outercurve Foundation. // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, @@ -41,54 +41,61 @@ using WebsitePanel.EnterpriseServer; namespace WebsitePanel.Portal.ProviderControls { - public partial class HostedSharePoint30_Settings : WebsitePanelControlBase, IHostingServiceProviderSettings - { - protected void Page_Load(object sender, EventArgs e) - { + public partial class HostedSharePoint30_Settings : WebsitePanelControlBase, IHostingServiceProviderSettings + { + protected void Page_Load(object sender, EventArgs e) + { - } + } - public void BindSettings(StringDictionary settings) - { - this.txtRootWebApplication.Text = settings["RootWebApplicationUri"]; - int selectedAddressid = this.FindAddressByText(settings["RootWebApplicationIpAddress"]); - this.ddlRootWebApplicationIpAddress.AddressId = (selectedAddressid > 0) ? selectedAddressid : 0; - txtBackupTempFolder.Text = settings["BackupTemporaryFolder"]; - } + public void BindSettings(StringDictionary settings) + { + this.txtRootWebApplication.Text = settings["RootWebApplicationUri"]; + int selectedAddressid = this.FindAddressByText(settings["RootWebApplicationIpAddress"]); + this.ddlRootWebApplicationIpAddress.AddressId = (selectedAddressid > 0) ? selectedAddressid : 0; + chkLocalHostFile.Checked = Utils.ParseBool(settings["LocalHostFile"], false); + this.txtSharedSSLRoot.Text = settings["SharedSSLRoot"]; + } - public void SaveSettings(StringDictionary settings) - { - settings["RootWebApplicationUri"] = this.txtRootWebApplication.Text; + public void SaveSettings(StringDictionary settings) + { + settings["RootWebApplicationUri"] = this.txtRootWebApplication.Text; + settings["LocalHostFile"] = chkLocalHostFile.Checked.ToString(); + settings["RootWebApplicationInteralIpAddress"] = String.Empty; + settings["SharedSSLRoot"] = this.txtSharedSSLRoot.Text; - if (ddlRootWebApplicationIpAddress.AddressId > 0) - { - IPAddressInfo address = ES.Services.Servers.GetIPAddress(ddlRootWebApplicationIpAddress.AddressId); + if (ddlRootWebApplicationIpAddress.AddressId > 0) + { + IPAddressInfo address = ES.Services.Servers.GetIPAddress(ddlRootWebApplicationIpAddress.AddressId); if (String.IsNullOrEmpty(address.ExternalIP)) - { + { settings["RootWebApplicationIpAddress"] = address.InternalIP; - } - else - { + } + else + { settings["RootWebApplicationIpAddress"] = address.ExternalIP; - } - } - else - { - settings["RootWebApplicationIpAddress"] = String.Empty; - } - settings["BackupTemporaryFolder"] = txtBackupTempFolder.Text; - } + } - private int FindAddressByText(string address) - { - foreach (IPAddressInfo addressInfo in ES.Services.Servers.GetIPAddresses(IPAddressPool.General, PanelRequest.ServerId)) - { - if (addressInfo.InternalIP == address || addressInfo.ExternalIP == address) - { - return addressInfo.AddressId; - } - } - return 0; - } - } + if (!String.IsNullOrEmpty(address.InternalIP)) + settings["RootWebApplicationInteralIpAddress"] = address.InternalIP; + } + else + { + settings["RootWebApplicationIpAddress"] = String.Empty; + } + + } + + private int FindAddressByText(string address) + { + foreach (IPAddressInfo addressInfo in ES.Services.Servers.GetIPAddresses(IPAddressPool.General, PanelRequest.ServerId)) + { + if (addressInfo.InternalIP == address || addressInfo.ExternalIP == address) + { + return addressInfo.AddressId; + } + } + return 0; + } + } } \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/HostedSharePoint30_Settings.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/HostedSharePoint30_Settings.ascx.designer.cs index 571fb7d0..edf10495 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/HostedSharePoint30_Settings.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/HostedSharePoint30_Settings.ascx.designer.cs @@ -1,10 +1,9 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.1434 // // Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// the code is regenerated. // //------------------------------------------------------------------------------ @@ -49,6 +48,33 @@ namespace WebsitePanel.Portal.ProviderControls { /// protected global::WebsitePanel.Portal.SelectIPAddress ddlRootWebApplicationIpAddress; + /// + /// chkLocalHostFile control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CheckBox chkLocalHostFile; + + /// + /// lblSharedSSLRoot control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblSharedSSLRoot; + + /// + /// txtSharedSSLRoot control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtSharedSSLRoot; + /// /// lblSharePointBackup control. /// diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/QuotaEditor.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/QuotaEditor.ascx.cs index dd5ecef4..0160b484 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/QuotaEditor.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/QuotaEditor.ascx.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2012, Outercurve Foundation. +// Copyright (c) 2011, Outercurve Foundation. // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, @@ -80,7 +80,7 @@ namespace WebsitePanel.Portal ? ParentQuotaValue : Math.Min(Utils.ParseInt(txtQuotaValue.Text, 0), ParentQuotaValue); } - } + } } set { @@ -108,10 +108,10 @@ namespace WebsitePanel.Portal } get { - return ViewState["ParentQuotaValue"] != null ? (int) ViewState["ParentQuotaValue"] : 0; + return ViewState["ParentQuotaValue"] != null ? (int)ViewState["ParentQuotaValue"] : 0; } } - + protected void Page_Load(object sender, EventArgs e) { WriteScriptBlock(); @@ -122,19 +122,19 @@ namespace WebsitePanel.Portal // set textbox attributes txtQuotaValue.Style["display"] = (txtQuotaValue.Text == "-1") ? "none" : "inline"; - - + + chkQuotaUnlimited.Attributes["onclick"] = String.Format("ToggleQuota('{0}', '{1}');", txtQuotaValue.ClientID, chkQuotaUnlimited.ClientID); - + // call base handler base.OnPreRender(e); } private void WriteScriptBlock() { - string scriptKey = "QuataScript"; + string scriptKey = "QuataScript"; if (!Page.ClientScript.IsClientScriptBlockRegistered(scriptKey)) { Page.ClientScript.RegisterClientScriptBlock(GetType(), scriptKey, @""); } - + } } } \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/QuotaEditor.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/QuotaEditor.ascx.designer.cs index 27444719..c535ae48 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/QuotaEditor.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/QuotaEditor.ascx.designer.cs @@ -1,10 +1,9 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.3053 // // Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// the code is regenerated. // //------------------------------------------------------------------------------