私は、Exchangeサーバーに接続しようとすると、私は401エラーを持っている:為替のWebサービス(EWS)は、Javaアピ:401権限
microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRequestException: The request failed. The request failed. The remote server returned an error: (401)Unauthorized
私は、同じユーザーID、userPwで(https://ewseditor.codeplex.com/でドメインをテストとURL)それは完全に動作します。
これは私の実際のコードです:
public static void main(String[] args)
{
try {
CustomExchangeService service = new CustomExchangeService(version);
ExchangeCredentials credentials = new WebCredentials(userId, userPw,domain);
service.setUrl(new URI(url));
service.setCredentials(credentials);
service.setTraceEnabled(true);
Folder.bind(getInstance().service, WellKnownFolderName.Inbox, PropertySet.IdOnly);
} catch (Exception e) {
e.printStackTrace();
}
}
そして、この方法でクラスCustomExchangeService:
protected Registry<ConnectionSocketFactory> createConnectionSocketFactoryRegistry() {
try {
return RegistryBuilder.<ConnectionSocketFactory>create()
.register(EWSConstants.HTTP_SCHEME, new PlainConnectionSocketFactory())
.register(EWSConstants.HTTPS_SCHEME, EwsSSLProtocolSocketFactory.build(
null, NoopHostnameVerifier.INSTANCE
))
.build();
} catch (GeneralSecurityException e) {
throw new RuntimeException(
"Could not initialize ConnectionSocketFactory instances for HttpClientConnectionManager", e
);
}
}
は、なぜ私はこのエラーがありますか?多分SSLの事のために?あなたの助け
それはあなたが別のエラーが返さなるだろうSSLた場合は、エラーが資格情報です。ユーザー名としてUPNを使用するだけの資格情報形式を確認し、資格情報のユーザー名、パスワードのみが必要です。 –
解決済み:サーバーでインターネットインフォメーションサービス(IIS)マネージャーを開きます。左に展開してEWSを見つけます。 401で認証を取得し、すべてのlignesをアクティブにClic。 – Gabriel