第一次尝试在 ASP.NET Web 应用程序中使用 AD 身份验证。尝试使用ActiveDirectoryMembershipProvider
该类获取有关用户的基本信息时,我收到一条错误消息The Active Directory Membership Provider has not been initialized.
这是我的 web.config:
<connectionStrings>
<add name="ADService" connectionString ="LDAP://AMAZON-A923C5B1.l5.chm.com/" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<membership defaultProvider="AspNetActiveDirectoryMembershipProvider">
<providers>
<add name="AspNetActiveDirectoryMembershipProvider"
type="System.Web.Security.ActiveDirectoryMembershipProvider,
System.Web, Version=2.0.3600, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="ADService"/>
</providers>
</membership>
这是我的代码:
ActiveDirectoryMembershipProvider provider = new ActiveDirectoryMembershipProvider();
if (this.Page.User.Identity.IsAuthenticated)
{
MembershipUser user = provider.GetUser(this.Page.User.Identity.Name, true);
LoginName loginName = HeadLoginView.FindControl("HeadLoginName") as LoginName;
loginName.FormatString = user.UserName;
}
}
这是我的错误: