2009-12-10 125 views
0

我無法在我的網站上獲取AD身份驗證。我有以下的測試代碼工作正常:Asp.net,Active Directory身份驗證不起作用

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,這是否會導致問題?

感謝您的幫助!

+0

你的連接字符串「ADAuthConnection」是什麼樣的? – 2009-12-10 06:20:11

+0

目前它的「LDAP://company.local/ou=Personel,ou = PersonelUsers,ou = OfficeX,dc = company,dc = local」,這種格式讓我的測試用例正常工作。 – Morri 2009-12-10 07:56:42

回答

0

你檢查出

How To: Use Membership in ASP.NET 2.0

它給出瞭如何設置和使用AD成員提供一個不錯的步行通過的?但看了那篇文章,似乎你正在做的一切正確...

除了我不知道你的AD連接​​字符串看起來像 - 你能告訴我們那條信息?

+0

這是我目前的格式 LDAP://company.local/ou=Personel,ou = PersonelUsers,ou = OfficeX,dc = company,dc = local 我試過不同的樣式。許多指南都提到使用cn = Users或類似的命令,但這會給我錯誤,我追蹤到「你不能在連接字符串中使用組」,所以我使用ou = xyz定義進行了測試 – Morri 2009-12-10 07:55:48

相關問題