2012-11-22 10 views
14

でADFSトークンを取得します。私たちは、クラスタが順番にメール/カレンダーへのアクセスを破った応答を停止どこに問題があった365PowerShellの

最近オフィスで私たちのActive Directoryドメインを連携するために使用されているADFS 2.0の環境を持っていますすべてのユーザー私たちは現在ADFSを監視していないため、定期的にADFSクラスタの認証を試み、testexchangeconnectivity.comのSSOテストと同様の有効なトークンを取得するPowerShellスクリプトを作成しようとしています。

トークンが実際に

/ADFS /サービス/信頼/ 2005/usernamemixed

によって発行されたことが表示されます

が、私は反対呼び出し、WebRequestクラスまたは新しいWebサービスプロキシを実行しようとするたびにこのURIとローカルAD資格情報を提供すると、私は400 Bad Requestエラーを受け取ります。

このエンドポイントからトークンを正しく要求するにはどうすればよいですか?

答えて

0

このスクリプトでは、あなたがまた、Office 365のPowerShellセッションに接続するための接続-MSOLコマンドレットを使用してADFSログオンをシミュレートすることができ.NET Frameworkの4.5

が必要になります http://gallery.technet.microsoft.com/scriptcenter/Invoke-ADFSSecurityTokenReq-09e9c90c あなたの方法を取得する必要があります - ADFSアカウントを使用すると、ADFSログインが発生します。

0

基本的に、WSTrustChannelFactoryを使用してチャンネルを作成し、RequestSecurityTokenに渡します。

レアンドロはあなたが.NET 4.5を使用していない場合、Windows Identity Foundation(WIF)をインストールする必要がありますsample

、素敵な簡潔なを持っています。

0

私は、WS-FederationとWS-Trustを使用してフェデレーション認証を行う製品で動作します。あなたのケースは私たちのワークフローの一部だと私は信じています。

私は、SOAPベースのAPIに対してPowerShellの自動化を開発しましたが、ある時点でその知識をギャラリーのWcfPSモジュールに統合しています。

モジュールのcodeはオープ​​ンソースであり、スクリプト内では、System.ServiceModelSystem.IdentityModelアセンブリの.netフレームワーククラスとアセンブリに大きく依存します。私は、これらのアセンブリ内のapiのほとんどが.NET標準2から利用できないため、このモジュールを言います。そのため、モジュールは残念なことにWindows以外のオペレーティングシステムでは動作しません。あなたは私のポストWCFPS - PowerShell module to work with SOAP endpointsでそれについてさらに読むことができます。

これは、サービスプロバイダの要件と信頼関係の構成に応じて対称トークンとベアラトークンを発行できる例です。このコードでは、フェデレーテッドセキュリティフロー、セットアップ、および用語の基本的な理解が必要です。

# Define the ADFS MEX uri 
$adfsMexUri="https://adfs.example.com/adfs/services/trust/mex" 

#region Define authentication endpoints. One for windows and one with username/password 
$windowsMixed13AuthenticationEndpoint="https://adfs.example.com/adfs/services/trust/13/windowsmixed" 
$usernamePasswordMixed13AuthenticationEndpoint="https://adfs.example.com/adfs/services/trust/13/usernamemixed" 
#endregion 

#region Define service providers for which we want to issue a symmetric and a bearer token respectively 
# Symmatric is for SOAP, WS-Trust 
# Bearer is for Web, WS-Federation 
$soapServiceProviderAppliesTo="https://myserviceprovider/Soap/" 
$webServiceProviderAppliesTo="https://myserviceprovider/Web/" 
#endregion 

# Parse the MEX and locate the service endpoint 
$issuerImporter=New-WcfWsdlImporter -Endpoint $adfsMexUri 

#region Issue tokens with windows authentications 
$issuerEndpoint=$issuerImporter | New-WcfServiceEndpoint -Endpoint $windowsMixed13AuthenticationEndpoint 
$soapToken=New-SecurityToken -Endpoint $issuerEndpoint -AppliesTo $soapServiceProviderAppliesTo -Symmetric 
$webToken=New-SecurityToken -Endpoint $issuerEndpoint -AppliesTo $webServiceProviderAppliesTo -Bearer 
#endregion 

#region Issue tokens with username/password credentials 
$credential=Get-Credential 
$issuerEndpoint=$issuerImporter | New-WcfServiceEndpoint -Endpoint $usernamePasswordMixed13AuthenticationEndpoint 
$soapToken=New-SecurityToken -Endpoint $issuerEndpoint -Credential $credential -AppliesTo $soapServiceProviderAppliesTo -Symmetric 
$webToken=New-SecurityToken -Endpoint $issuerEndpoint -Credential $credential -AppliesTo $webServiceProviderAppliesTo -Bearer  
#endregion