merge commit
This commit is contained in:
commit
097b3fe90b
22 changed files with 673 additions and 111 deletions
|
@ -718,28 +718,42 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
string server = GetServerName();
|
||||
string securityGroupPath = AddADPrefix(securityGroup);
|
||||
|
||||
//Create mail enabled organization security group
|
||||
EnableMailSecurityDistributionGroup(runSpace, securityGroup, organizationId);
|
||||
transaction.RegisterMailEnabledDistributionGroup(securityGroup);
|
||||
UpdateSecurityDistributionGroup(runSpace, securityGroup, organizationId, IsConsumer);
|
||||
bool enableDefaultGroup = !string.IsNullOrEmpty(securityGroup);
|
||||
|
||||
if (enableDefaultGroup)
|
||||
{
|
||||
//Create mail enabled organization security group
|
||||
EnableMailSecurityDistributionGroup(runSpace, securityGroup, organizationId);
|
||||
transaction.RegisterMailEnabledDistributionGroup(securityGroup);
|
||||
UpdateSecurityDistributionGroup(runSpace, securityGroup, organizationId, IsConsumer);
|
||||
}
|
||||
|
||||
//create GAL
|
||||
string galId = CreateGlobalAddressList(runSpace, organizationId);
|
||||
transaction.RegisterNewGlobalAddressList(galId);
|
||||
ExchangeLog.LogInfo(" Global Address List: {0}", galId);
|
||||
UpdateGlobalAddressList(runSpace, galId, securityGroupPath);
|
||||
if (enableDefaultGroup)
|
||||
{
|
||||
UpdateGlobalAddressList(runSpace, galId, securityGroupPath);
|
||||
}
|
||||
|
||||
//create AL
|
||||
string alId = CreateAddressList(runSpace, organizationId);
|
||||
transaction.RegisterNewAddressList(alId);
|
||||
ExchangeLog.LogInfo(" Address List: {0}", alId);
|
||||
UpdateAddressList(runSpace, alId, securityGroupPath);
|
||||
if (enableDefaultGroup)
|
||||
{
|
||||
UpdateAddressList(runSpace, alId, securityGroupPath);
|
||||
}
|
||||
|
||||
//create RAL
|
||||
string ralId = CreateRoomsAddressList(runSpace, organizationId);
|
||||
transaction.RegisterNewRoomsAddressList(ralId);
|
||||
ExchangeLog.LogInfo(" Rooms Address List: {0}", ralId);
|
||||
UpdateAddressList(runSpace, ralId, securityGroupPath);
|
||||
if (enableDefaultGroup)
|
||||
{
|
||||
UpdateAddressList(runSpace, ralId, securityGroupPath);
|
||||
}
|
||||
|
||||
//create ActiveSync policy
|
||||
string asId = CreateActiveSyncPolicy(runSpace, organizationId);
|
||||
|
@ -837,12 +851,18 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
|
||||
string server = GetOABGenerationServerName();
|
||||
|
||||
string securityGroupId = AddADPrefix(securityGroup);
|
||||
|
||||
//create OAB
|
||||
string oabId = CreateOfflineAddressBook(runSpace, organizationId, server, oabVirtualDir);
|
||||
transaction.RegisterNewOfflineAddressBook(oabId);
|
||||
UpdateOfflineAddressBook(runSpace, oabId, securityGroupId);
|
||||
|
||||
bool enableDefaultGroup = !string.IsNullOrEmpty(securityGroup);
|
||||
|
||||
if (enableDefaultGroup)
|
||||
{
|
||||
string securityGroupId = AddADPrefix(securityGroup);
|
||||
UpdateOfflineAddressBook(runSpace, oabId, securityGroupId);
|
||||
}
|
||||
|
||||
info.OfflineAddressBook = oabId;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -996,7 +1016,12 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
//disable mail security distribution group
|
||||
try
|
||||
{
|
||||
DisableMailSecurityDistributionGroup(runSpace, securityGroup);
|
||||
bool enableDefaultGroup = !string.IsNullOrEmpty(securityGroup);
|
||||
|
||||
if (enableDefaultGroup)
|
||||
{
|
||||
DisableMailSecurityDistributionGroup(runSpace, securityGroup);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -3771,7 +3796,25 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
id = GetPSObjectIdentity(obj);
|
||||
account = GetExchangeAccount(runSpace, id);
|
||||
if (account != null)
|
||||
{
|
||||
list.Add(account);
|
||||
}
|
||||
else
|
||||
{
|
||||
string distinguishedName = (string)GetPSObjectProperty(obj, "DistinguishedName");
|
||||
string path = ActiveDirectoryUtils.AddADPrefix(distinguishedName, PrimaryDomainController);
|
||||
|
||||
if (ActiveDirectoryUtils.AdObjectExists(path))
|
||||
{
|
||||
DirectoryEntry entry = ActiveDirectoryUtils.GetADObject(path);
|
||||
|
||||
list.Add(new ExchangeAccount
|
||||
{
|
||||
AccountName = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.SAMAccountName),
|
||||
AccountType = ExchangeAccountType.SecurityGroup
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
ExchangeLog.LogEnd("GetGroupMembers");
|
||||
return list.ToArray();
|
||||
|
@ -4068,7 +4111,12 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
string id = AddPublicFolder(runSpace, folderName, parentFolder);
|
||||
transaction.RegisterNewPublicFolder(string.Empty, id);
|
||||
|
||||
SetPublicFolderPermissions(runSpace, id, securityGroup);
|
||||
bool enableDefaultGroup = !string.IsNullOrEmpty(securityGroup);
|
||||
|
||||
if (enableDefaultGroup)
|
||||
{
|
||||
SetPublicFolderPermissions(runSpace, id, securityGroup);
|
||||
}
|
||||
|
||||
if (mailEnabled)
|
||||
{
|
||||
|
|
|
@ -92,28 +92,42 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
string server = GetServerName();
|
||||
string securityGroupPath = AddADPrefix(securityGroup);
|
||||
|
||||
//Create mail enabled organization security group
|
||||
EnableMailSecurityDistributionGroup(runSpace, securityGroup, organizationId);
|
||||
transaction.RegisterMailEnabledDistributionGroup(securityGroup);
|
||||
UpdateSecurityDistributionGroup(runSpace, securityGroup, organizationId, IsConsumer);
|
||||
bool enableDefaultGroup = !string.IsNullOrEmpty(securityGroup);
|
||||
|
||||
if (enableDefaultGroup)
|
||||
{
|
||||
//Create mail enabled organization security group
|
||||
EnableMailSecurityDistributionGroup(runSpace, securityGroup, organizationId);
|
||||
transaction.RegisterMailEnabledDistributionGroup(securityGroup);
|
||||
UpdateSecurityDistributionGroup(runSpace, securityGroup, organizationId, IsConsumer);
|
||||
}
|
||||
|
||||
//create GAL
|
||||
string galId = CreateGlobalAddressList(runSpace, organizationId);
|
||||
transaction.RegisterNewGlobalAddressList(galId);
|
||||
ExchangeLog.LogInfo(" Global Address List: {0}", galId);
|
||||
UpdateGlobalAddressList(runSpace, galId, securityGroupPath);
|
||||
if (enableDefaultGroup)
|
||||
{
|
||||
UpdateGlobalAddressList(runSpace, galId, securityGroupPath);
|
||||
}
|
||||
|
||||
//create AL
|
||||
string alId = CreateAddressList(runSpace, organizationId);
|
||||
transaction.RegisterNewAddressList(alId);
|
||||
ExchangeLog.LogInfo(" Address List: {0}", alId);
|
||||
UpdateAddressList(runSpace, alId, securityGroupPath);
|
||||
if (enableDefaultGroup)
|
||||
{
|
||||
UpdateAddressList(runSpace, alId, securityGroupPath);
|
||||
}
|
||||
|
||||
//create RAL
|
||||
string ralId = CreateRoomsAddressList(runSpace, organizationId);
|
||||
transaction.RegisterNewRoomsAddressList(ralId);
|
||||
ExchangeLog.LogInfo(" Rooms Address List: {0}", ralId);
|
||||
UpdateAddressList(runSpace, ralId, securityGroupPath);
|
||||
if (enableDefaultGroup)
|
||||
{
|
||||
UpdateAddressList(runSpace, ralId, securityGroupPath);
|
||||
}
|
||||
|
||||
//create ActiveSync policy
|
||||
string asId = CreateActiveSyncPolicy(runSpace, organizationId);
|
||||
|
@ -283,7 +297,12 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
//disable mail security distribution group
|
||||
try
|
||||
{
|
||||
DisableMailSecurityDistributionGroup(runSpace, securityGroup);
|
||||
bool enableDefaultGroup = !string.IsNullOrEmpty(securityGroup);
|
||||
|
||||
if (enableDefaultGroup)
|
||||
{
|
||||
DisableMailSecurityDistributionGroup(runSpace, securityGroup);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -206,12 +206,12 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
return ActiveDirectoryUtils.AdObjectExists(orgPath);
|
||||
}
|
||||
|
||||
public Organization CreateOrganization(string organizationId)
|
||||
public Organization CreateOrganization(string organizationId, bool enableDefaultGroup)
|
||||
{
|
||||
return CreateOrganizationInternal(organizationId);
|
||||
return CreateOrganizationInternal(organizationId, enableDefaultGroup);
|
||||
}
|
||||
|
||||
internal Organization CreateOrganizationInternal(string organizationId)
|
||||
internal Organization CreateOrganizationInternal(string organizationId, bool enableDefaultGroup)
|
||||
{
|
||||
HostedSolutionLog.LogStart("CreateOrganizationInternal");
|
||||
HostedSolutionLog.DebugInfo("OrganizationId : {0}", organizationId);
|
||||
|
@ -232,15 +232,20 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
ActiveDirectoryUtils.CreateOrganizationalUnit(organizationId, parentPath);
|
||||
ouCreated = true;
|
||||
|
||||
//Create security group
|
||||
ActiveDirectoryUtils.CreateGroup(orgPath, organizationId);
|
||||
groupCreated = true;
|
||||
|
||||
if (enableDefaultGroup)
|
||||
{
|
||||
//Create security group
|
||||
ActiveDirectoryUtils.CreateGroup(orgPath, organizationId);
|
||||
groupCreated = true;
|
||||
}
|
||||
|
||||
org = new Organization();
|
||||
org.OrganizationId = organizationId;
|
||||
org.DistinguishedName = ActiveDirectoryUtils.RemoveADPrefix(orgPath);
|
||||
org.SecurityGroup = ActiveDirectoryUtils.RemoveADPrefix(GetGroupPath(organizationId));
|
||||
org.SecurityGroup = enableDefaultGroup
|
||||
? ActiveDirectoryUtils.RemoveADPrefix(GetGroupPath(organizationId))
|
||||
: "";
|
||||
|
||||
org.GroupName = organizationId;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -356,13 +361,15 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
throw new ArgumentNullException("organizationId");
|
||||
|
||||
string groupPath = GetGroupPath(organizationId);
|
||||
ActiveDirectoryUtils.DeleteADObject(groupPath);
|
||||
try
|
||||
{
|
||||
ActiveDirectoryUtils.DeleteADObject(groupPath);
|
||||
}
|
||||
catch { /* skip */ }
|
||||
|
||||
string path = GetOrganizationPath(organizationId);
|
||||
ActiveDirectoryUtils.DeleteADObject(path, true);
|
||||
|
||||
|
||||
|
||||
HostedSolutionLog.LogEnd("DeleteOrganizationInternal");
|
||||
}
|
||||
|
||||
|
@ -371,12 +378,12 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
|
||||
#region Users
|
||||
|
||||
public int CreateUser(string organizationId, string loginName, string displayName, string upn, string password, bool enabled)
|
||||
public int CreateUser(string organizationId, string loginName, string displayName, string upn, string password, bool enabled, bool enableDefaultGroup)
|
||||
{
|
||||
return CreateUserInternal(organizationId, loginName, displayName, upn, password, enabled);
|
||||
return CreateUserInternal(organizationId, loginName, displayName, upn, password, enabled, enableDefaultGroup);
|
||||
}
|
||||
|
||||
internal int CreateUserInternal(string organizationId, string loginName, string displayName, string upn, string password, bool enabled)
|
||||
internal int CreateUserInternal(string organizationId, string loginName, string displayName, string upn, string password, bool enabled, bool enableDefaultGroup)
|
||||
{
|
||||
HostedSolutionLog.LogStart("CreateUserInternal");
|
||||
HostedSolutionLog.DebugInfo("organizationId : {0}", organizationId);
|
||||
|
@ -414,12 +421,14 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
return Errors.AD_OBJECT_ALREADY_EXISTS;
|
||||
}
|
||||
|
||||
string groupPath = GetGroupPath(organizationId);
|
||||
HostedSolutionLog.DebugInfo("Group retrieved: {0}", groupPath);
|
||||
if (enableDefaultGroup)
|
||||
{
|
||||
string groupPath = GetGroupPath(organizationId);
|
||||
HostedSolutionLog.DebugInfo("Group retrieved: {0}", groupPath);
|
||||
|
||||
|
||||
ActiveDirectoryUtils.AddObjectToGroup(userPath, groupPath);
|
||||
HostedSolutionLog.DebugInfo("Added to group: {0}", groupPath);
|
||||
ActiveDirectoryUtils.AddObjectToGroup(userPath, groupPath);
|
||||
HostedSolutionLog.DebugInfo("Added to group: {0}", groupPath);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -1015,12 +1024,18 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
|
||||
ActiveDirectoryUtils.SetADObjectProperty(entry, ADAttributes.Notes, notes);
|
||||
|
||||
foreach (string userPath in ActiveDirectoryUtils.GetGroupObjects(groupName, "user"))
|
||||
entry.CommitChanges();
|
||||
|
||||
string orgPath = GetOrganizationPath(organizationId);
|
||||
|
||||
DirectoryEntry orgEntry = ActiveDirectoryUtils.GetADObject(orgPath);
|
||||
|
||||
foreach (string userPath in ActiveDirectoryUtils.GetGroupObjects(groupName, "user", orgEntry))
|
||||
{
|
||||
ActiveDirectoryUtils.RemoveObjectFromGroup(userPath, path);
|
||||
}
|
||||
|
||||
foreach (string groupPath in ActiveDirectoryUtils.GetGroupObjects(groupName, "group"))
|
||||
foreach (string groupPath in ActiveDirectoryUtils.GetGroupObjects(groupName, "group", orgEntry))
|
||||
{
|
||||
ActiveDirectoryUtils.RemoveObjectFromGroup(groupPath, path);
|
||||
}
|
||||
|
@ -1029,9 +1044,7 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
{
|
||||
string objPath = GetObjectPath(organizationId, obj);
|
||||
ActiveDirectoryUtils.AddObjectToGroup(objPath, path);
|
||||
}
|
||||
|
||||
entry.CommitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public void AddObjectToSecurityGroup(string organizationId, string accountName, string groupName)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue