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.
This commit is contained in:
robvde 2012-07-01 08:24:49 +04:00
parent 38592df9e6
commit a0d9e59db2
25 changed files with 3174 additions and 2256 deletions

View file

@ -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)

View file

@ -136,6 +136,7 @@ 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 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

View file

@ -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,
@ -96,7 +96,7 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
List<ServiceProviderItem> items = PackageController.GetPackageItemsByType(org.PackageId, typeof(SharePointSiteCollection), false);
items.ConvertAll<SharePointSiteCollection>(delegate(ServiceProviderItem item) { return (SharePointSiteCollection)item; });
List<SharePointSiteCollection> ret = new List<SharePointSiteCollection>();
foreach(ServiceProviderItem item in items)
foreach (ServiceProviderItem item in items)
{
SharePointSiteCollection siteCollection = item as SharePointSiteCollection;
if (siteCollection != null && siteCollection.OrganizationId == organizationId)
@ -116,7 +116,7 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
{
if (IsDemoMode)
{
return new int[] {1033};
return new int[] { 1033 };
}
// Log operation.
@ -125,7 +125,7 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
int serviceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.HostedSharePoint);
if (serviceId == 0)
{
return new int[]{};
return new int[] { };
}
try
@ -196,7 +196,7 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
{
if (IsDemoMode)
{
return GetSiteCollections(1, false)[itemId-1];
return GetSiteCollections(1, false)[itemId - 1];
}
SharePointSiteCollection item = PackageController.GetPackageItem(itemId) as SharePointSiteCollection;
@ -210,7 +210,7 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
/// <returns>Created site collection id within metabase.</returns>
public static int AddSiteCollection(SharePointSiteCollection item)
{
string domainName = item.Name;
// Check account.
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
if (accountCheck < 0)
@ -241,9 +241,48 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
{
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);
@ -253,10 +292,14 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
item.PhysicalAddress = item.Name;
}
Organization org = OrganizationController.GetOrganization(item.OrganizationId);
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.
@ -274,39 +317,43 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
HostedSharePointServer hostedSharePointServer = GetHostedSharePointServer(serviceId);
hostedSharePointServer.CreateSiteCollection(item);
// 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 = domain.WebSiteName;
string website = siteName;
if (!String.IsNullOrEmpty(domain.WebSiteName))
{
DnsRecord[] records = ServerController.GetDnsZoneRecords(domain.DomainId);
foreach (DnsRecord record in records)
{
if (record.RecordType.Equals(DnsRecordType.A) && String.IsNullOrEmpty(record.RecordName))
if (record.RecordType.Equals(DnsRecordType.A) && (record.RecordName == hostName))
{
ServerController.DeleteDnsZoneRecord(domain.DomainId, String.Empty, DnsRecordType.A, record.RecordData);
ServerController.DeleteDnsZoneRecord(domain.DomainId, hostName, DnsRecordType.A, record.RecordData);
break;
}
}
}
ServerController.AddDnsZoneRecord(domain.DomainId, String.Empty, DnsRecordType.A, hostedSharePointSettings["RootWebApplicationIpAddress"], 0);
ServerController.AddDnsZoneRecord(domain.DomainId, hostName, DnsRecordType.A, hostedSharePointSettings["RootWebApplicationIpAddress"], 0);
}
}
TaskManager.ItemId = itemId;
return itemId;
}
catch(Exception ex)
catch (Exception ex)
{
throw TaskManager.WriteError(ex);
}
@ -331,7 +378,7 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
}
// Load original meta item
SharePointSiteCollection origItem = (SharePointSiteCollection) PackageController.GetPackageItem(itemId);
SharePointSiteCollection origItem = (SharePointSiteCollection)PackageController.GetPackageItem(itemId);
if (origItem == null)
{
return BusinessErrorCodes.ERROR_SHAREPOINT_PACKAGE_ITEM_NOT_FOUND;
@ -340,7 +387,7 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
// 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);
string siteName = origItem.Name.Replace(String.Format("{0}://", rootWebApplicationUri.Scheme), String.Empty);
// Log operation.
TaskManager.StartTask("HOSTEDSHAREPOINT", "DELETE_SITE", origItem.Name);
@ -350,36 +397,23 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
{
// Delete site collection on server.
HostedSharePointServer hostedSharePointServer = GetHostedSharePointServer(origItem.ServiceId);
hostedSharePointServer.DeleteSiteCollection(origItem.Url);
hostedSharePointServer.DeleteSiteCollection(origItem);
// Delete record in metabase.
PackageController.DeletePackageItem(origItem.Id);
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));
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, hostedSharePointSettings["RootWebApplicationIpAddress"]);
}
}
}
}
}
return 0;
}
@ -853,7 +887,7 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
GetOrganizationSharePointSiteCollections(org.Id);
foreach( SharePointSiteCollection siteCollection in currentOrgSiteCollection)
foreach (SharePointSiteCollection siteCollection in currentOrgSiteCollection)
{
try
{
@ -865,7 +899,7 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
hostedSharePointServer.UpdateQuotas(siteCollection.PhysicalAddress, realMaxSizeValue,
warningStorage);
}
catch(Exception ex)
catch (Exception ex)
{
TaskManager.WriteError(ex);
}
@ -901,7 +935,7 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
TaskManager.ItemId = itemId;
try
{
Organization org = (Organization) PackageController.GetPackageItem(itemId);
Organization org = (Organization)PackageController.GetPackageItem(itemId);
if (org == null)
return null;
@ -927,7 +961,7 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
retDiskSpace[0].Url = string.Empty;
}
}
catch(Exception ex)
catch (Exception ex)
{
throw TaskManager.WriteError(ex);
}
@ -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;
@ -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);
}

View file

@ -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,
@ -65,6 +65,11 @@ 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;
@ -98,8 +103,8 @@ namespace WebsitePanel.Providers.HostedSolution
public bool Disabled
{
get { return disabled;}
set { disabled = value;}
get { return disabled; }
set { disabled = value; }
}
public string FirstName
@ -269,6 +274,29 @@ namespace WebsitePanel.Providers.HostedSolution
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; }
}
}
}

View file

@ -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,
@ -73,7 +73,7 @@ namespace WebsitePanel.Providers.SharePoint
/// When implemented deletes site collection under given url.
/// </summary>
/// <param name="url">Url that uniquely identifies site collection to be deleted.</param>
void DeleteSiteCollection(string url);
void DeleteSiteCollection(SharePointSiteCollection siteCollection);
/// <summary>
/// When implemeneted backups site collection under give url.
@ -114,5 +114,7 @@ namespace WebsitePanel.Providers.SharePoint
SharePointSiteDiskSpace[] CalculateSiteCollectionsDiskSpace(string[] urls);
long GetSiteCollectionSize(string url);
void SetPeoplePickerOu(string site, string ou);
}
}

View file

@ -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
}
}
/// <summary>
/// Gets or sets the internal ip address
/// </summary>
[Persistent]
public string RootWebApplicationInteralIpAddress
{
get
{
return this.rootWebApplicationInteralIpAddress;
}
set
{
this.rootWebApplicationInteralIpAddress = value;
}
}
/// <summary>
/// Gets or sets the internal ip address
/// </summary>
[Persistent]
public string RootWebApplicationFQDN
{
get
{
return this.rootWebApplicationFQDN;
}
set
{
this.rootWebApplicationFQDN = value;
}
}
/// <summary>
/// Gets or sets locale id of the site collection to be created.
/// </summary>

View file

@ -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,
@ -127,11 +127,11 @@ namespace WebsitePanel.Providers.HostedSolution
/// Deletes site collection under given url.
/// </summary>
/// <param name="url">Url that uniquely identifies site collection to be deleted.</param>
public void DeleteSiteCollection(string url)
public void DeleteSiteCollection(SharePointSiteCollection siteCollection)
{
ExecuteSharePointAction<object>(delegate(HostedSharePointServerImpl impl)
{
impl.DeleteSiteCollection(RootWebApplicationUri, url);
impl.DeleteSiteCollection(RootWebApplicationUri, siteCollection);
return null;
});
}
@ -227,7 +227,7 @@ namespace WebsitePanel.Providers.HostedSolution
{
try
{
DeleteSiteCollection((item as SharePointSiteCollection).Url);
DeleteSiteCollection((SharePointSiteCollection)item);
}
catch (Exception ex)
{
@ -307,7 +307,7 @@ namespace WebsitePanel.Providers.HostedSolution
{
// Create instance of server implementation in a separate application domain for
// security and isolation purposes.
Type type = typeof (HostedSharePointServerImpl);
Type type = typeof(HostedSharePointServerImpl);
AppDomainSetup info = new AppDomainSetup();
info.ApplicationBase = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
info.PrivateBinPath = "bin; bin/debug";
@ -342,9 +342,9 @@ namespace WebsitePanel.Providers.HostedSolution
}
public SharePointSiteDiskSpace[] CalculateSiteCollectionsDiskSpace(string []urls)
public SharePointSiteDiskSpace[] CalculateSiteCollectionsDiskSpace(string[] urls)
{
SharePointSiteDiskSpace []sd = null;
SharePointSiteDiskSpace[] sd = null;
sd = ExecuteSharePointAction<SharePointSiteDiskSpace[]>(delegate(HostedSharePointServerImpl impl)
{
return impl.CalculateSiteCollectionDiskSpace(RootWebApplicationUri, urls);
@ -366,5 +366,10 @@ namespace WebsitePanel.Providers.HostedSolution
return ret;
}
public virtual void SetPeoplePickerOu(string site, string ou)
{
}
}
}

View file

@ -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<PSObject> ExecuteShellCommand(Runspace runSpace, Command cmd)
{
return ExecuteShellCommand(runSpace, cmd, true);
}
internal Collection<PSObject> ExecuteShellCommand(Runspace runSpace, Command cmd, bool useDomainController)
{
object[] errors;
return ExecuteShellCommand(runSpace, cmd, useDomainController, out errors);
}
internal Collection<PSObject> ExecuteShellCommand(Runspace runSpace, Command cmd, out object[] errors)
{
return ExecuteShellCommand(runSpace, cmd, true, out errors);
}
internal Collection<PSObject> ExecuteShellCommand(Runspace runSpace, Command cmd, bool useDomainController, out object[] errors)
{
HostedSolutionLog.LogStart("ExecuteShellCommand");
List<object> errorList = new List<object>();
HostedSolutionLog.DebugCommand(cmd);
Collection<PSObject> 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;
}
/// <summary>
/// Returns the distinguished name of the object from the shell execution result
/// </summary>
/// <param name="result"></param>
/// <returns></returns>
internal string GetResultObjectDN(Collection<PSObject> 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;
}
/// <summary>
/// Checks the object from the shell execution result.
/// </summary>
/// <param name="result"></param>
/// <returns>Distinguished name of the object if object exists or null otherwise.</returns>
internal string CheckResultObjectDN(Collection<PSObject> 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;
}
/// <summary>
/// Returns the identity of the object from the shell execution result
/// </summary>
/// <param name="result"></param>
/// <returns></returns>
internal string GetResultObjectIdentity(Collection<PSObject> 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;
}
/// <summary>
/// Returns the identity of the PS object
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
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<SharePointSiteCollection> siteCollections = new List<SharePointSiteCollection>();
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");
}
}
}

View file

@ -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,
@ -50,20 +50,35 @@ namespace WebsitePanel.Providers.HostedSolution
public int[] GetSupportedLanguages(string languagePacksPath)
{
List<int> languages = new List<int>();
string rootDirectory = FileUtils.EvaluateSystemVariables(languagePacksPath);
foreach (string dir in Directory.GetDirectories(rootDirectory))
try
{
int languageId = 0;
if (Int32.TryParse(dir.Replace(rootDirectory, String.Empty), out languageId))
WindowsImpersonationContext wic = WindowsIdentity.GetCurrent().Impersonate();
try
{
languages.Add(languageId);
}
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)
public long GetSiteCollectionSize(Uri root, string url)
{
WindowsImpersonationContext wic = null;
@ -109,7 +124,7 @@ namespace WebsitePanel.Providers.HostedSolution
SharePointSiteDiskSpace siteDiskSpace = new SharePointSiteDiskSpace();
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();
@ -145,7 +160,7 @@ namespace WebsitePanel.Providers.HostedSolution
List<SharePointSiteCollection> siteCollections = new List<SharePointSiteCollection>();
foreach(SPSite site in rootWebApplication.Sites)
foreach (SPSite site in rootWebApplication.Sites)
{
SharePointSiteCollection loadedSiteCollection = new SharePointSiteCollection();
FillSiteCollection(loadedSiteCollection, site);
@ -230,7 +245,7 @@ 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;
@ -260,6 +275,7 @@ namespace WebsitePanel.Providers.HostedSolution
public void CreateSiteCollection(Uri rootWebApplicationUri, SharePointSiteCollection siteCollection)
{
WindowsImpersonationContext wic = null;
HostedSolutionLog.LogStart("CreateSiteCollection");
try
{
@ -267,12 +283,14 @@ 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);
@ -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;
}
catch(Exception ex)
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)
{
HostedSolutionLog.LogError(ex);
throw;
@ -318,6 +405,8 @@ namespace WebsitePanel.Providers.HostedSolution
{
if (wic != null)
wic.Undo();
HostedSolutionLog.LogEnd("CreateSiteCollection");
}
}
@ -327,7 +416,7 @@ namespace WebsitePanel.Providers.HostedSolution
/// <param name="rootWebApplicationUri">Root web application uri.</param>
/// <param name="url">Url that uniquely identifies site collection to be deleted.</param>
/// <exception cref="InvalidOperationException">Is thrown in case requested operation fails for any reason.</exception>
public void DeleteSiteCollection(Uri rootWebApplicationUri, string url)
public void DeleteSiteCollection(Uri rootWebApplicationUri, SharePointSiteCollection siteCollection)
{
try
{
@ -337,7 +426,7 @@ namespace WebsitePanel.Providers.HostedSolution
try
{
SPWebApplication rootWebApplication = SPWebApplication.Lookup(rootWebApplicationUri);
string siteCollectionUrl = String.Format("{0}:{1}", url, rootWebApplicationUri.Port);
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";
@ -358,13 +447,71 @@ namespace WebsitePanel.Providers.HostedSolution
rootWebApplication.Sites.Delete(siteCollectionUrl, true);
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' });
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 (hostName.ToLower() != siteCollection.RootWebApplicationFQDN.ToLower())
{
outPut += s + "\r\n";
}
}
else
outPut += s + "\r\n";
}
}
FileUtils.UpdateFileTextContent(path, outPut);
}
}
}
catch (Exception ex)
{
HostedSolutionLog.LogError(ex);
}
}
finally
{
wic.Undo();
}
}
catch(Exception ex)
catch (Exception ex)
{
throw new InvalidOperationException("Failed to delete site collection.", ex);
}
@ -416,7 +563,7 @@ namespace WebsitePanel.Providers.HostedSolution
wic.Undo();
}
}
catch(Exception ex)
catch (Exception ex)
{
throw new InvalidOperationException("Failed to backup site collection.", ex);
}
@ -489,7 +636,7 @@ namespace WebsitePanel.Providers.HostedSolution
wic.Undo();
}
}
catch(Exception ex)
catch (Exception ex)
{
throw new InvalidOperationException("Failed to restore site collection.", ex);
}
@ -501,7 +648,7 @@ namespace WebsitePanel.Providers.HostedSolution
/// </summary>
/// <param name="customSiteCollection">Custom site collection to fill.</param>
/// <param name="site">Administration object.</param>
private static void FillSiteCollection (SharePointSiteCollection customSiteCollection, SPSite site)
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;

View file

@ -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
{
@ -122,5 +124,21 @@ namespace WebsitePanel.Providers.HostedSolution
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());
}
}
}

View file

@ -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,
@ -130,7 +130,7 @@ namespace WebsitePanel.Server
[WebMethod, SoapHeader("settings")]
public SharePointSiteDiskSpace[] CalculateSiteCollectionsDiskSpace(string[] urls)
{
SharePointSiteDiskSpace []ret = null;
SharePointSiteDiskSpace[] ret = null;
ret = ExecuteAction<SharePointSiteDiskSpace[]>(delegate
{
return HostedSharePointServerProvider.CalculateSiteCollectionsDiskSpace(urls);
@ -143,15 +143,14 @@ namespace WebsitePanel.Server
/// </summary>
/// <param name="url">Url that uniquely identifies site collection to be deleted.</param>
[WebMethod, SoapHeader("settings")]
public void DeleteSiteCollection(string url)
public void DeleteSiteCollection(SharePointSiteCollection siteCollection)
{
ExecuteAction<object>(delegate
{
HostedSharePointServerProvider.DeleteSiteCollection(url);
HostedSharePointServerProvider.DeleteSiteCollection(siteCollection);
return new object();
}, "DeleteSiteCollection");
}
/// <summary>
/// Backups site collection under give url.
/// </summary>
@ -230,6 +229,14 @@ namespace WebsitePanel.Server
}, "GetSiteCollectionSize");
}
[WebMethod, SoapHeader("settings")]
public void SetPeoplePickerOu(string site, string ou)
{
HostedSharePointServerProvider.SetPeoplePickerOu(site, ou);
}
/// <summary>
/// Executes supplied action and performs logging.
/// </summary>

View file

@ -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()

View file

@ -49,7 +49,7 @@
<asp:Image ID="img1" runat="server" ImageUrl='<%# GetAccountImage() %>' ImageAlign="AbsMiddle" />
<asp:LinkButton ID="cmdSelectAccount" CommandName="SelectAccount"
CommandArgument='<%# Eval("AccountName").ToString() + "|" + Eval("DisplayName").ToString() + "|" + Eval("PrimaryEmailAddress")+ "|" + Eval("AccountId")%>'
CommandArgument='<%# Eval("AccountName").ToString() + "|" + Eval("DisplayName").ToString() + "|" + Eval("PrimaryEmailAddress")+ "|" + Eval("AccountId")+ "|" + Eval("SamAccountName")%>'
runat="server" Text='<%# Eval("DisplayName") %>'></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>

View file

@ -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.
//
@ -51,6 +51,61 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
}
}
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; }
@ -66,6 +121,12 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
return (string)ViewState["AccountName"];
}
public string GetSAMAccountName()
{
return (string)ViewState["SAMAccountName"];
}
public string GetDisplayName()
{
return (string)ViewState["DisplayName"];
@ -96,6 +157,7 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
ViewState["DisplayName"] = account.DisplayName;
ViewState["PrimaryEmailAddress"] = account.PrimaryEmailAddress;
ViewState["AccountId"] = account.AccountId;
ViewState["SAMAccountName"] = account.SamAccountName;
}
else
{
@ -104,6 +166,7 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
ViewState["DisplayName"] = null;
ViewState["PrimaryEmailAddress"] = null;
ViewState["AccountId"] = null;
ViewState["SAMAccountName"] = null;
}
}
@ -128,6 +191,41 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
accounts = updatedAccounts.ToArray();
}
if (IncludeMailboxesOnly)
{
List<OrganizationUser> updatedAccounts = new List<OrganizationUser>();
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<OrganizationUser> updatedAccounts = new List<OrganizationUser>();
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();
}
Array.Sort(accounts, CompareAccount);
if (Direction == SortDirection.Ascending)
{
@ -144,7 +242,7 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
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)
@ -188,6 +286,7 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
account.DisplayName = parts[1];
account.PrimaryEmailAddress = parts[2];
account.AccountId = Utils.ParseInt(parts[3]);
account.SamAccountName = parts[4];
// set account
BindSelectedAccount(account);

View file

@ -1,7 +1,6 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.

View file

@ -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" %>
<wsp:EnableAsyncTasksSupport id="asyncTasks" runat="server" />
<div id="ExchangeContainer">
<div class="Module">
<div class="Header">
@ -39,13 +32,18 @@
<wsp:SimpleMessageBox id="localMessageBox" runat="server">
</wsp:SimpleMessageBox>
<table id="tblEditItem" runat="server" cellspacing="0" cellpadding="5" width="100%">
<tr>
<tr id="rowUrl">
<td class="SubHead" nowrap width="200">
<asp:Label ID="lblSiteCollectionUrl" runat="server" meta:resourcekey="lblSiteCollectionUrl"
Text="Url:"></asp:Label>
</td>
<td width="100%" class="NormalBold">
<wsp:DomainSelector id="domain" runat="server" ShowAt="false"/>
<asp:TextBox ID="txtHostName" runat="server" CssClass="TextBox100" MaxLength="64"></asp:TextBox>.<uc1:DomainsSelectDomainControl ID="domain" runat="server" HideWebSites="true" HideDomainPointers="true" />
<asp:RequiredFieldValidator ID="valRequireHostName" runat="server" meta:resourcekey="valRequireHostName" ControlToValidate="txtHostName"
ErrorMessage="Enter hostname" ValidationGroup="CreateSite" Display="Dynamic" Text="*" SetFocusOnError="True"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="valRequireCorrectHostName" runat="server"
ErrorMessage="Enter valid hostname" ControlToValidate="txtHostName" Display="Dynamic"
meta:resourcekey="valRequireCorrectHostName" ValidationExpression="^([0-9a-zA-Z])*[0-9a-zA-Z]+$" SetFocusOnError="True"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>

View file

@ -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,6 +35,7 @@ using WebsitePanel.Providers.DNS;
using WebsitePanel.Providers.HostedSolution;
using WebsitePanel.Providers.SharePoint;
namespace WebsitePanel.Portal
{
public partial class HostedSharePointEditSiteCollection : WebsitePanelModuleBase
@ -59,6 +60,8 @@ namespace WebsitePanel.Portal
protected void Page_Load(object sender, EventArgs e)
{
domain.PackageId = PanelSecurity.PackageId;
warningStorage.UnlimitedText = GetLocalizedString("WarningUnlimitedValue");
editWarningStorage.UnlimitedText = GetLocalizedString("WarningUnlimitedValue");
@ -77,8 +80,6 @@ namespace WebsitePanel.Portal
// bind item
BindItem();
//this.RegisterOwnerSelector();
}
private void BindItem()
@ -109,6 +110,13 @@ namespace WebsitePanel.Portal
{
// new item
ViewState["PackageId"] = PanelSecurity.PackageId;
if (UseSharedSLL(PanelSecurity.PackageId))
{
rowUrl.Visible = false;
valRequireHostName.Enabled = false;
valRequireCorrectHostName.Enabled = false;
}
}
//this.gvUsers.DataBind();
@ -155,7 +163,11 @@ namespace WebsitePanel.Portal
}
}
OrganizationDomainName[] domains = ES.Services.Organizations.GetOrganizationDomains(PanelRequest.ItemID);
//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)
{
@ -199,26 +211,35 @@ namespace WebsitePanel.Portal
// new item
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.domain.DomainName))
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 = 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.OwnerLogin = this.userSelector.GetSAMAccountName();
item.OwnerEmail = this.userSelector.GetPrimaryEmailAddress();
item.OwnerName = this.userSelector.GetDisplayName();
item.Title = txtTitle.Text;
@ -312,9 +333,10 @@ namespace WebsitePanel.Portal
{
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()));
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)
@ -323,11 +345,36 @@ namespace WebsitePanel.Portal
}
private void RedirectToSiteCollectionsList()
{
Response.Redirect(EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "sharepoint_sitecollections", "ItemID=" + PanelRequest.ItemID.ToString()));
}
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;
}
break;
}
}
}
return false;
}
//private void RegisterOwnerSelector()
//{
// // Define the name and type of the client scripts on the page.

View file

@ -1,7 +1,6 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
@ -76,6 +75,15 @@ namespace WebsitePanel.Portal {
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlTable tblEditItem;
/// <summary>
/// rowUrl control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlTableRow rowUrl;
/// <summary>
/// lblSiteCollectionUrl control.
/// </summary>
@ -85,6 +93,15 @@ namespace WebsitePanel.Portal {
/// </remarks>
protected global::System.Web.UI.WebControls.Label lblSiteCollectionUrl;
/// <summary>
/// txtHostName control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox txtHostName;
/// <summary>
/// domain control.
/// </summary>
@ -92,7 +109,25 @@ namespace WebsitePanel.Portal {
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::WebsitePanel.Portal.ExchangeServer.UserControls.DomainSelector domain;
protected global::WebsitePanel.Portal.DomainsSelectDomainControl domain;
/// <summary>
/// valRequireHostName control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.RequiredFieldValidator valRequireHostName;
/// <summary>
/// valRequireCorrectHostName control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.RegularExpressionValidator valRequireCorrectHostName;
/// <summary>
/// lblSiteCollectionOwner control.

View file

@ -112,11 +112,14 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="chkLocalHostFile" xml:space="preserve">
<value>Provision local hosts file</value>
</data>
<data name="lblBackupTempFolder.Text" xml:space="preserve">
<value>SharePoint Backup Temporary Folder:</value>
</data>
@ -126,9 +129,15 @@
<data name="lblRootWebApplicationIpAddress.Text" xml:space="preserve">
<value>SharePoint Web Application IP:</value>
</data>
<data name="lblSharedSSLRoot.Text" xml:space="preserve">
<value>Shared SSL Root:</value>
</data>
<data name="lblSharePointBackup.Text" xml:space="preserve">
<value>SharePoint Backup</value>
</data>
<data name="lblWildCardRoot.Text" xml:space="preserve">
<value>Wildcard Certificate Root</value>
</data>
<data name="lclTempBackupNote.Text" xml:space="preserve">
<value>Please note that WebsitePanel Server account should have access to this folder. Leave this field blank to use default path.</value>
</data>

View file

@ -18,6 +18,20 @@
<wsp:SelectIPAddress ID="ddlRootWebApplicationIpAddress" runat="server" ServerIdParam="ServerID" AllowEmptySelection="false" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:CheckBox ID="chkLocalHostFile" runat="server" meta:resourcekey="chkLocalHostFile" Text="Provision localhost file" />
</td>
</tr>
<tr>
<td class="SubHead" width="200" nowrap>
<asp:Label ID="lblSharedSSLRoot" runat="server" meta:resourcekey="lblSharedSSLRoot" Text="Shared SSL Root:"></asp:Label>
</td>
<td width="100%">
<asp:TextBox ID="txtSharedSSLRoot" runat="server" CssClass="NormalTextBox" Width="200px"></asp:TextBox>
</td>
</tr>
</table>
<fieldset>
@ -39,4 +53,5 @@
</table>
</fieldset>
<br />

View file

@ -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,
@ -53,12 +53,16 @@ namespace WebsitePanel.Portal.ProviderControls
this.txtRootWebApplication.Text = settings["RootWebApplicationUri"];
int selectedAddressid = this.FindAddressByText(settings["RootWebApplicationIpAddress"]);
this.ddlRootWebApplicationIpAddress.AddressId = (selectedAddressid > 0) ? selectedAddressid : 0;
txtBackupTempFolder.Text = settings["BackupTemporaryFolder"];
chkLocalHostFile.Checked = Utils.ParseBool(settings["LocalHostFile"], false);
this.txtSharedSSLRoot.Text = settings["SharedSSLRoot"];
}
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)
{
@ -71,12 +75,15 @@ namespace WebsitePanel.Portal.ProviderControls
{
settings["RootWebApplicationIpAddress"] = address.ExternalIP;
}
if (!String.IsNullOrEmpty(address.InternalIP))
settings["RootWebApplicationInteralIpAddress"] = address.InternalIP;
}
else
{
settings["RootWebApplicationIpAddress"] = String.Empty;
}
settings["BackupTemporaryFolder"] = txtBackupTempFolder.Text;
}
private int FindAddressByText(string address)

View file

@ -1,7 +1,6 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
@ -49,6 +48,33 @@ namespace WebsitePanel.Portal.ProviderControls {
/// </remarks>
protected global::WebsitePanel.Portal.SelectIPAddress ddlRootWebApplicationIpAddress;
/// <summary>
/// chkLocalHostFile control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.CheckBox chkLocalHostFile;
/// <summary>
/// lblSharedSSLRoot control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label lblSharedSSLRoot;
/// <summary>
/// txtSharedSSLRoot control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox txtSharedSSLRoot;
/// <summary>
/// lblSharePointBackup control.
/// </summary>

View file

@ -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,
@ -108,7 +108,7 @@ namespace WebsitePanel.Portal
}
get
{
return ViewState["ParentQuotaValue"] != null ? (int) ViewState["ParentQuotaValue"] : 0;
return ViewState["ParentQuotaValue"] != null ? (int)ViewState["ParentQuotaValue"] : 0;
}
}

View file

@ -1,7 +1,6 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.