사용자가 회사 네트워크 사용자 이름과 암호를 입력해야하는 웹 사이트가 있습니다. 그런 다음 Active Directory에서 해당 계정을 찾고 해당 계정과 연결된 모든 전자 메일 주소의 목록을 가져옵니다.첫 번째 시도에서 Active Directory 계정 잠김
내가 가지고있는 문제는 잘못된 암호로 인해 계정이 잠겨 있다는 것입니다. 우리의 도메인 정책은 3 개의 잘못된 항목 후에 계정이 잠길 것이므로 내 코드에서 뭔가 잘못하고 있다고 가정합니다. 필자는 일반적으로 Active Directory 또는 .NET DirectoryServices에 대해 잘 알고 있지 않습니다. 이는 내 코드에서 분명히 드러납니다. 여기있다 :
public ArrayList AuthenticateActiveDirectory(string Domain, string UserName, string Password)
{
// An error occurs if the username/password combo does not exist.
// That is how we know it is not a valid entry.
try
{
DirectoryEntry entry = new DirectoryEntry("LDAP://" + Domain, UserName, Password);
object nativeObject = entry.NativeObject;
ArrayList emails = new ArrayList();
DirectorySearcher ds = new DirectorySearcher(entry);
ds.Filter = "samaccountname=" + UserName;
ds.PropertiesToLoad.Add("mail");
SearchResult sr = ds.FindOne();
if (sr.Properties["mail"] != null)
{
for (int email = 0; email < sr.Properties["mail"].Count; email++)
{
emails.Add(sr.Properties["mail"][email]);
}
}
return emails;
}
catch (DirectoryServicesCOMException) { throw; }
catch (Exception) { throw; }
}
'catch (Exception) {throw; }'? –
Nothing :) 나는 거기에 추가 처리가 필요할 수도 있다고 생각하는 경우 가끔 있습니다. 디버깅 할 때도 사용하며, 여기에서 이러한 예외가 발생할 수 있다는 추가 알림으로 사용됩니다. – MJB