asp.netmvc2.0サイトで非常に単純なLdapクエリを使用しています。
文字列ldapPath=ConfigReader.LdapPath; 文字列emailAddress=null;
try
{
DirectorySearcher search = new DirectorySearcher(ConfigReader.LdapPath);
search.Filter = String.Format("(&(objectClass=user)(objectCategory=person)(objectSid={0})) ", securityIdentifierValue);
// add the mail property to the list of props to retrieve
search.PropertiesToLoad.Add("mail");
var result = search.FindOne();
if (result == null)
{
throw new Exception("Ldap Query with filter:" + search.Filter.ToString() + " returned a null value (no match found)");
}
else
{
emailAddress = result.Properties["mail"][0].ToString();
}
}
catch (ArgumentOutOfRangeException aoorEx)
{
throw new Exception( "The query could not find an email for this user.");
}
catch (Exception ex)
{
//_log.Error(string.Format("======!!!!!! ERROR ERROR ERROR !!!!! in LdapLookupUtil.cs getEmailFromLdap Exception: {0}", ex));
throw ex;
}
return emailAddress;
それは私のローカルホストマシンで正常に動作します。サーバー上のVS2010で実行すると、正常に動作します。デプロイすると常にnullの結果を返します。
これが私のweb.configです。
VisualStudioのAsp.Net構成オプション。設定とコメントの完全なリストは、通常\ Windows \ Microsoft.Net \ Framework \ v2.x\Config->にあるmachine.config.commentsにあります。
セクションを使用すると、ASP.NETが着信ユーザーを識別するために使用するセキュリティ認証モードを構成できます。->
<!--
->セクションでは、リクエストの実行中に未処理のエラーが発生した場合の対処方法を設定できます。具体的には、開発者は、エラースタックトレースの代わりに表示されるhtmlエラーページを構成できます。->
デフォルトのアプリプールで実行しています。
誰かが問題を見ていますか?これは私を夢中にさせています!