현재 사용자가 인증되었는지 확인하는 방법이 있지만 내 ASP.net 응용 프로그램이 기본 로그인으로 ActiveDirectory 인증을 구현하도록하고 싶습니다.web.config 및 기본 로그인에서 Active Directory 인증
내 현재의 방법은 :
그것은 나타납니다<membership defaultProvider="MembershipADProvider">
<providers>
<add
name="MembershipADProvider"
type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="ADConnectionString"
/>
</providers>
</membership>
가 LDAP 서버에 연결할 수 : Web.config의에서 로그인 기능을 구현하려고
public bool IsAuthenticated(string user, string pass)
{
bool authenticated = false;
string path = "LDAP://my path here";
DirectoryEntry adsEntry = new DirectoryEntry(path);
adsEntry.AuthenticationType = AuthenticationTypes.Secure;
adsEntry.Username = user;
adsEntry.Password = pass;
DirectorySearcher adsSearcher = new DirectorySearcher(adsEntry);
adsSearcher.Filter = "(sAMAccountName=" + user + ")";
try
{
SearchResult adsSearchResult = adsSearcher.FindOne();
authenticated = true;
adsEntry.Close();
}
catch (Exception ex)
{
// Failed to authenticate. Most likely it is caused by unknown user
// id or bad strPassword.
//strError = ex.Message;
adsEntry.Close();
}
return authenticated;
나는 다음과 같이 썼다 , Bad username or password valdiation error
을 던지면서. 다른면에서는 3 서버 인증을 시도한 후이 서버가 다른 모든 응용 프로그램에서 사용자를 차단하기 때문에 서버에 연결할지 여부는 확실하지 않습니다. connectionUsername
및 connectionPassword
속성을 web.config에 추가해야하거나, 로그인시 Login
명령을 각 사용자 이름/비밀번호로 채우도록해야할지 확실하지 않습니다. 어떤 도움을 주시면 감사하겠습니다.