Fixed: Access Denied for Exchange 2013 CU2

This commit is contained in:
robvde 2013-07-31 22:42:21 +04:00
parent 09d848c5ab
commit 65c1ec0ffc
3 changed files with 25 additions and 3 deletions

View file

@ -55,6 +55,8 @@ using Microsoft.Exchange.Data;
using Microsoft.Exchange.Data.Directory; using Microsoft.Exchange.Data.Directory;
using Microsoft.Exchange.Data.Storage; using Microsoft.Exchange.Data.Storage;
using Microsoft.Web.Administration;
namespace WebsitePanel.Providers.HostedSolution namespace WebsitePanel.Providers.HostedSolution
{ {
public class Exchange2013 : HostingServiceProviderBase, IExchangeServer public class Exchange2013 : HostingServiceProviderBase, IExchangeServer
@ -5930,14 +5932,27 @@ namespace WebsitePanel.Providers.HostedSolution
if (connectionInfo == null) if (connectionInfo == null)
{ {
PSCredential credential = (PSCredential)null; ServerManager mgr = new ServerManager();
ApplicationPool myAppPool = mgr.ApplicationPools["WebsitePanel Server Pool"];
SecureString password = new SecureString();
string str_password = myAppPool.ProcessModel.Password;
string username = myAppPool.ProcessModel.UserName;
foreach (char x in str_password)
{
password.AppendChar(x);
}
PSCredential credential = new PSCredential(username, password);
connectionInfo = new WSManConnectionInfo(new Uri(PowerShellUrl), connectionInfo = new WSManConnectionInfo(new Uri(PowerShellUrl),
"http://schemas.microsoft.com/powershell/Microsoft.Exchange", "http://schemas.microsoft.com/powershell/Microsoft.Exchange",
credential); credential);
connectionInfo.AuthenticationMechanism = AuthenticationMechanism.NegotiateWithImplicitCredential; connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Negotiate;
connectionInfo.SkipCNCheck = true; connectionInfo.SkipCNCheck = true;
connectionInfo.SkipCACheck = true;
} }
Runspace runSpace = RunspaceFactory.CreateRunspace(connectionInfo); Runspace runSpace = RunspaceFactory.CreateRunspace(connectionInfo);
@ -5945,7 +5960,7 @@ namespace WebsitePanel.Providers.HostedSolution
runSpace.Open(); runSpace.Open();
ExchangeLog.LogEnd("OpenRunspace"); ExchangeLog.LogEnd("OpenRunspace");
Command cmd = new Command("Set-ADServerSettings"); Command cmd = new Command("Set-ADServerSettings");
cmd.Parameters.Add("PreferredServer", PrimaryDomainController); cmd.Parameters.Add("PreferredServer", PrimaryDomainController);
ExecuteShellCommand(runSpace, cmd, false); ExecuteShellCommand(runSpace, cmd, false);

View file

@ -60,6 +60,10 @@
<HintPath>..\..\Lib\References\Microsoft\Exchange2013\Microsoft.Exchange.Net.dll</HintPath> <HintPath>..\..\Lib\References\Microsoft\Exchange2013\Microsoft.Exchange.Net.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="Microsoft.Web.Administration, Version=7.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Lib\References\Microsoft\Microsoft.Web.Administration.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.DirectoryServices" /> <Reference Include="System.DirectoryServices" />

View file

@ -211,12 +211,14 @@
<Compile Include="Code\UserControls\Tab.cs" /> <Compile Include="Code\UserControls\Tab.cs" />
<Compile Include="ExchangeServer\ExchangeDistributionListMemberOf.ascx.cs"> <Compile Include="ExchangeServer\ExchangeDistributionListMemberOf.ascx.cs">
<DependentUpon>ExchangeDistributionListMemberOf.ascx</DependentUpon> <DependentUpon>ExchangeDistributionListMemberOf.ascx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile> </Compile>
<Compile Include="ExchangeServer\ExchangeDistributionListMemberOf.ascx.designer.cs"> <Compile Include="ExchangeServer\ExchangeDistributionListMemberOf.ascx.designer.cs">
<DependentUpon>ExchangeDistributionListMemberOf.ascx</DependentUpon> <DependentUpon>ExchangeDistributionListMemberOf.ascx</DependentUpon>
</Compile> </Compile>
<Compile Include="ExchangeServer\ExchangeMailboxMemberOf.ascx.cs"> <Compile Include="ExchangeServer\ExchangeMailboxMemberOf.ascx.cs">
<DependentUpon>ExchangeMailboxMemberOf.ascx</DependentUpon> <DependentUpon>ExchangeMailboxMemberOf.ascx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile> </Compile>
<Compile Include="ExchangeServer\ExchangeMailboxMemberOf.ascx.designer.cs"> <Compile Include="ExchangeServer\ExchangeMailboxMemberOf.ascx.designer.cs">
<DependentUpon>ExchangeMailboxMemberOf.ascx</DependentUpon> <DependentUpon>ExchangeMailboxMemberOf.ascx</DependentUpon>
@ -251,6 +253,7 @@
</Compile> </Compile>
<Compile Include="ExchangeServer\OrganizationUserMemberOf.ascx.cs"> <Compile Include="ExchangeServer\OrganizationUserMemberOf.ascx.cs">
<DependentUpon>OrganizationUserMemberOf.ascx</DependentUpon> <DependentUpon>OrganizationUserMemberOf.ascx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile> </Compile>
<Compile Include="ExchangeServer\OrganizationUserMemberOf.ascx.designer.cs"> <Compile Include="ExchangeServer\OrganizationUserMemberOf.ascx.designer.cs">
<DependentUpon>OrganizationUserMemberOf.ascx</DependentUpon> <DependentUpon>OrganizationUserMemberOf.ascx</DependentUpon>