0

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エラーページを構成できます。->

デフォルトのアプリプールで実行しています。

誰かが問題を見ていますか?これは私を夢中にさせています!

4

1 に答える 1

0

OK、追加するのを忘れていましたが、デフォルト アプリケーション プールを実行しているユーザー アカウントを、LDAP クエリを実行するための認証を持つユーザーに変更しました。

于 2010-05-11T00:24:47.413 に答える