DirectoryEntry.Exists(String) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
确定指定路径是否表示目录服务实际项。
public:
static bool Exists(System::String ^ path);
public static bool Exists (string path);
static member Exists : string -> bool
Public Shared Function Exists (path As String) As Boolean
参数
- path
- String
要验证的项路径。
返回
如果指定路径表示目录服务实际项,则为 true
;否则为 false
。
示例
以下示例采用一个参数并确定路径是否对应于有效的 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
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);
}
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);
}