我無法在我的網站上獲取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,這是否會導致問題?
感謝您的幫助!
你的連接字符串「ADAuthConnection」是什麼樣的? – 2009-12-10 06:20:11
目前它的「LDAP://company.local/ou=Personel,ou = PersonelUsers,ou = OfficeX,dc = company,dc = local」,這種格式讓我的測試用例正常工作。 – Morri 2009-12-10 07:56:42