2016-04-07 28 views
0

我使用LDAP在Active Directory中搜索部門的名字,但它拋出異常時,它必須顯示,異常是使用LDAP

InvalidCastException的是未處理的Active Directory搜索

代碼:

If dSearchResult.Properties.Contains("department") 
Then 
    If dSearchResult.Properties("department")(0).ToString 

投擲異常在ToString

請幫忙。

回答

0

您使用cast syntax - 你想要的是該屬性的索引和值:

Dim department As String 
department = dSearchResult.Properties["department"][0].ToString