質問

今日は奇妙なことに気づいた。私が作業しているプロジェクトでは、このようなコードがいくつかあります。

var directoryEntry =new DirectoryEntry(
    ConfigurationManager.AppSettings["path"],
    ConfigurationManager.AppSettings["user"], 
    ConfigurationManager.AppSettings["password"]
);
.

これはクラスライブラリの一部です。別のプロジェクトからこのライブラリを使用したとき、アプリケーション/サイトの.configファイルにそれらのキーを定義するのを忘れましたが、まだ機能しました。

私の疑いは、このコンストラクタがPrincipalContextコンストラクター http://と同様に機能することです。MSDN.microsoft.com/en-us/library/bb298328.aspx .MSDNのドキュメントはそれについて何も言わないが、現在のユーザの資格情報を使用しているという点で、現在のユーザの資格情報を使用すること。

これを確認または拒否することができますか?

役に立ちましたか?

解決

This code sample is not throwing an exception but that doesn't mean it's necessarily working. The DirectoryEntry constructor doesn't do any type of authentication or validation of the values that are passed to it. Instead it merely stores these values which it will later attempt to use in order to make a query on the server.

This particular code won't throw or fail with empty strings but any call on it which causes it to bind to the server will very likely fail.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top