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.Storage;
using Microsoft.Web.Administration;
namespace WebsitePanel.Providers.HostedSolution
{
public class Exchange2013 : HostingServiceProviderBase, IExchangeServer
@ -5930,14 +5932,27 @@ namespace WebsitePanel.Providers.HostedSolution
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),
"http://schemas.microsoft.com/powershell/Microsoft.Exchange",
credential);
connectionInfo.AuthenticationMechanism = AuthenticationMechanism.NegotiateWithImplicitCredential;
connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Negotiate;
connectionInfo.SkipCNCheck = true;
connectionInfo.SkipCACheck = true;
}
Runspace runSpace = RunspaceFactory.CreateRunspace(connectionInfo);

View file

@ -60,6 +60,10 @@
<HintPath>..\..\Lib\References\Microsoft\Exchange2013\Microsoft.Exchange.Net.dll</HintPath>
<Private>False</Private>
</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.Core" />
<Reference Include="System.DirectoryServices" />

View file

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