Asp.net、Active Directory 身份验证不起作用

发布于 2024-08-14 03:58:04 字数 1322 浏览 4 评论 0原文

我在我的网站上无法进行 AD 身份验证。我有以下工作正常的测试代码:

DirectoryEntry entry = new DirectoryEntry(srvr, usr, pwd);
object nativeObject = entry.NativeObject;

在我的网站上,我收到错误“您的登录尝试未成功。请重试。”。我真的无法弄清楚阻止登录的过程中的根本错误是什么。

以下是我的 web.config 中的部分:

<authentication mode="Forms">
    <forms loginUrl="Default.aspx" 
     timeout="30" 
     name=".ADAuthCookie" 
     path="/" 
     requireSSL="false" 
     slidingExpiration="true" 
     defaultUrl="Edit.aspx" 
     cookieless="UseCookies" 
     enableCrossAppRedirects="false"/>
</authentication>
<authorization>
    <allow users="*"/>
</authorization>
<membership defaultProvider="MyADMembershipProvider">
    <providers>
        <add name="MyADMembershipProvider" 
         type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
         connectionStringName="ADAuthConnection" 
         applicationName="/" 
         connectionProtection="Secure" 
         enableSearchMethods="true" 
         connectionUsername="company\usr" 
         connectionPassword="pwd"/>
    </providers>
</membership>

这不应该是所需的全部内容吗?我不打算使用配置文件,所以我没有配置 ProfileProvider,这会导致问题吗?

感谢您的帮助!

I'm having trouble getting AD authentication working on my website. I have the following test code that works fine :

DirectoryEntry entry = new DirectoryEntry(srvr, usr, pwd);
object nativeObject = entry.NativeObject;

On my website I get an error "Your login attempt was not successful. Please try again.". I really haven't been able to figure out what's the underlying error in the process that prevents the login.

Here are the sections in my web.config :

<authentication mode="Forms">
    <forms loginUrl="Default.aspx" 
     timeout="30" 
     name=".ADAuthCookie" 
     path="/" 
     requireSSL="false" 
     slidingExpiration="true" 
     defaultUrl="Edit.aspx" 
     cookieless="UseCookies" 
     enableCrossAppRedirects="false"/>
</authentication>
<authorization>
    <allow users="*"/>
</authorization>
<membership defaultProvider="MyADMembershipProvider">
    <providers>
        <add name="MyADMembershipProvider" 
         type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
         connectionStringName="ADAuthConnection" 
         applicationName="/" 
         connectionProtection="Secure" 
         enableSearchMethods="true" 
         connectionUsername="company\usr" 
         connectionPassword="pwd"/>
    </providers>
</membership>

Shouldn't this be all that is required? I don't plan to use profile so I haven't configured ProfileProvider, could this cause the problems?

Thanks for help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷爱 2024-08-21 03:58:04

您是否查看了

如何:在 ASP.NET 2.0 中使用成员身份

其中很好地介绍了如何设置和使用 AD 会员资格提供商?但浏览一下那篇文章,似乎你做的一切都是正确的......

除了我不知道你的 AD 连接字符串是什么样的 - 你能给我们展示那条信息吗?

Did you check out the

How To: Use Membership in ASP.NET 2.0

which gives a nice walk-through of how to set up and use AD membership provider? But glancing over that article, it seems you're doing everything right...

Except I don't know what your AD connection string looks like - can you show us that piece of information??

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文