次の方法で共有


DirectoryEntry.Exists メソッド

指定したパスでディレクトリ ストアを検索して、エントリが存在するかどうかを確認します。

Public Shared Function Exists( _
   ByVal path As String _) As Boolean
[C#]
public static bool Exists(stringpath);
[C++]
public: static bool Exists(String* path);
[JScript]
public static function Exists(
   path : String) : Boolean;

パラメータ

  • path
    ディレクトリ ストアを検索するパス。

戻り値

指定したパスのディレクトリ ストアにエントリが存在する場合は true 。それ以外の場合は false

使用例

[Visual Basic, C#, C++] 1 つの引数を受け取り、有効な DirectoryEntry に対応するパスかどうかを調べる例を次に示します。

 
Dim myADSPath As String = "LDAP://onecity/CN=Users,DC=onecity,DC=corp,DC=fabrikam,DC=com"
' Determine whether the given path is correct for the DirectoryEntry.
If DirectoryEntry.Exists(myADSPath) Then
   Console.WriteLine("The path {0} is valid",myADSPath)
Else
   Console.WriteLine("The path {0} is invalid",myADSPath)
End If

[C#] 
string myADSPath ="LDAP://onecity/CN=Users,DC=onecity,DC=corp,DC=fabrikam,DC=com";

// Determine whether the given path is correct for the DirectoryEntry.
if (DirectoryEntry.Exists(myADSPath))
{
    Console.WriteLine("The path {0} is valid",myADSPath);
}
    else
{
    Console.WriteLine("The path {0} is invalid",myADSPath);
}

[C++] 
String* myADSPath = S"LDAP://onecity/CN=Users,DC=onecity,DC=corp,DC=fabrikam,DC=com";
// Determine whether the given path is correct for the DirectoryEntry.
if (DirectoryEntry::Exists(myADSPath)) {
    Console::WriteLine(S"The path {0} is valid", myADSPath);
} else {
    Console::WriteLine(S"The path {0} is invalid", myADSPath);
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

.NET Framework セキュリティ:

参照

DirectoryEntry クラス | DirectoryEntry メンバ | System.DirectoryServices 名前空間