ADSI 메서드 호출
ADSI 인터페이스에서 IDispatch 인터페이스를 지원하면 Invoke 메서드를 사용하여 해당 인터페이스의 메서드에 액세스할 수 있습니다. 이전에 추가한 ADSI 확장에도 같은 내용이 적용됩니다. Invoke 메서드를 사용하기 위해 ADSI 라이브러리를 포함할 필요가 없습니다.
기본 메서드가 실패하면 TargetInvocationException 예외가 throw될 수도 있습니다. TargetInvocationException 개체의 InnerException 속성은 발생한 실제 오류에 대한 정보를 포함하는 COMException 개체입니다.
다음 C# 예제에서는 IADsUser 인터페이스 SetPassword 메서드를 호출하여 암호를 설정하는 방법을 보여 줍니다. IADsUser 인터페이스 또는 SetPassword 메서드에 대한 자세한 내용은 MSDN Library(https://go.microsoft.com/fwlink/?LinkID=27252)의 "IADsUser" 또는 "IADsUser::SetPassword"를 참조하십시오.
DirectoryEntry usr = new DirectoryEntry("LDAP://CN=John Smith, DC=Fabrikam,DC=COM");
usr.Invoke("SetPassword", new object[] {SecurelyStoredPassword});
다음 C# 예제에서는 IADsUser 인터페이스 ChangePassword 메서드를 호출하여 암호를 변경하는 방법을 보여 줍니다. IADsUser 인터페이스 또는 ChangePassword 메서드에 대한 자세한 내용은 MSDN Library(https://go.microsoft.com/fwlink/?LinkID=27252)의 "IADsUser" 또는 "IADsUser::ChangePassword"를 참조하십시오.
DirectoryEntry usr = new DirectoryEntry("LDAP://CN=John Smith, DC=Fabrikam,DC=COM");
usr.Invoke("ChangePassword", new object[] {SecurelyStoredPassword, NewSecurelyStoredPassword});
다음 C# 예제에서는 IADsGroup 인터페이스 Members 메서드를 호출하여 그룹 멤버를 검색하는 방법을 보여 줍니다. IADsGroup 인터페이스 또는 Members 메서드에 대한 자세한 내용은 MSDN Library(https://go.microsoft.com/fwlink/?LinkID=27252)의 "IADsGroup" 또는 "IADsGroup::Members"를 참조하십시오.
DirectoryEntry grpEntry = new DirectoryEntry("LDAP://CN=Enterprise Admins,CN=Users,DC=Fabrikam, DC=com");
object members = grpEntry.Invoke("Members",null);
foreach( object member in (IEnumerable) members)
{
DirectoryEntry x = new DirectoryEntry(member);
Console.WriteLine(x.Name);
}
참고 항목
참조
System.DirectoryServices
DirectoryEntry
TargetInvocationException
COMException
TargetInvocationException
개념
Send comments about this topic to Microsoft.
Copyright © 2007 by Microsoft Corporation. All rights reserved.