EDN Admin
Well-known member
Im having a problem with part of my application Im trying to get the directory entry for a computer object in AD (it could be mutiple computer objects based on whether or not the users passes a wild card for the object name). These names would be added
add a child node of the parent node "Computers" in the tree view. Im just having problems with using the search results...
as usual any help would be appreciated...
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Private <span style="color:Blue; Sub Form2_Load(<span style="color:Blue; ByVal sender <span style="color:Blue; As System.Object, <span style="color:Blue; ByVal e <span style="color:Blue; As System.EventArgs) <span style="color:Blue; Handles <span style="color:Blue; MyBase.Load
<span style="color:Blue; Dim parentCNNode <span style="color:Blue; As TreeNode = <span style="color:Blue; New TreeNode(<span style="color:#A31515; "cn")
TreeView1.Nodes.Add(<span style="color:#A31515; "Computers")
<span style="color:Blue; Try
<span style="color:Blue; Dim entry <span style="color:Blue; As <span style="color:Blue; New DirectoryEntry(<span style="color:#A31515; "LDAP://DC=***,DC=***")
<span style="color:Blue; Dim mySearcher <span style="color:Blue; As <span style="color:Blue; New DirectorySearcher(entry)
mySearcher.Filter = <span style="color:#A31515; "(&(objectClass=computer)(name=" & strComputerName & <span style="color:#A31515; "))"
<span style="color:Blue; Dim results <span style="color:Blue; As SearchResultCollection = mySearcher.FindAll()
<span style="color:Blue; Dim result <span style="color:Blue; As SearchResult
<span style="color:Blue; For <span style="color:Blue; Each result <span style="color:Blue; In results
Console.WriteLine(<span style="color:Blue; CStr(result), <span style="color:#A31515; "testing")
ProgressBar1.Value = (ProgressBar1.Value + 1) <span style="color:Blue; Mod ProgressBar1.Maximum
<span style="color:Blue; Next
ProgressBar1.Value = 0
<span style="color:Blue; Catch comEx <span style="color:Blue; As System.Runtime.InteropServices.COMException
Console.WriteLine(comEx)
<span style="color:Blue; Catch invOpEx <span style="color:Blue; As InvalidOperationException
Console.WriteLine(invOpEx)
<span style="color:Blue; Catch notSuppEx <span style="color:Blue; As NotSupportedException
Console.WriteLine(notSuppEx)
<span style="color:Blue; End <span style="color:Blue; Try
<span style="color:Blue; End <span style="color:Blue; Sub
[/code]
View the full article
add a child node of the parent node "Computers" in the tree view. Im just having problems with using the search results...
as usual any help would be appreciated...
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Private <span style="color:Blue; Sub Form2_Load(<span style="color:Blue; ByVal sender <span style="color:Blue; As System.Object, <span style="color:Blue; ByVal e <span style="color:Blue; As System.EventArgs) <span style="color:Blue; Handles <span style="color:Blue; MyBase.Load
<span style="color:Blue; Dim parentCNNode <span style="color:Blue; As TreeNode = <span style="color:Blue; New TreeNode(<span style="color:#A31515; "cn")
TreeView1.Nodes.Add(<span style="color:#A31515; "Computers")
<span style="color:Blue; Try
<span style="color:Blue; Dim entry <span style="color:Blue; As <span style="color:Blue; New DirectoryEntry(<span style="color:#A31515; "LDAP://DC=***,DC=***")
<span style="color:Blue; Dim mySearcher <span style="color:Blue; As <span style="color:Blue; New DirectorySearcher(entry)
mySearcher.Filter = <span style="color:#A31515; "(&(objectClass=computer)(name=" & strComputerName & <span style="color:#A31515; "))"
<span style="color:Blue; Dim results <span style="color:Blue; As SearchResultCollection = mySearcher.FindAll()
<span style="color:Blue; Dim result <span style="color:Blue; As SearchResult
<span style="color:Blue; For <span style="color:Blue; Each result <span style="color:Blue; In results
Console.WriteLine(<span style="color:Blue; CStr(result), <span style="color:#A31515; "testing")
ProgressBar1.Value = (ProgressBar1.Value + 1) <span style="color:Blue; Mod ProgressBar1.Maximum
<span style="color:Blue; Next
ProgressBar1.Value = 0
<span style="color:Blue; Catch comEx <span style="color:Blue; As System.Runtime.InteropServices.COMException
Console.WriteLine(comEx)
<span style="color:Blue; Catch invOpEx <span style="color:Blue; As InvalidOperationException
Console.WriteLine(invOpEx)
<span style="color:Blue; Catch notSuppEx <span style="color:Blue; As NotSupportedException
Console.WriteLine(notSuppEx)
<span style="color:Blue; End <span style="color:Blue; Try
<span style="color:Blue; End <span style="color:Blue; Sub
[/code]
View the full article