This works in VB6 but not VB.net

T

Ty

Hello all I am trying to port over an application that interacts with
Active Directory which worked fine in VB6 but chokes in VB.net at this
line.

container.Filter = Array("Computer")

From some research I have found that this needs a variant array which
seems to be a problem in VB.net.

Here is the code above the problem line.
Dim container As IADsContainer

container = GetObject("WinNT://" & containername)

container.Filter = Array("Computer")

Any help would be appreciated.

Ty
 
A

Armin Zingler

Ty said:
Hello all I am trying to port over an application that interacts with
Active Directory which worked fine in VB6 but chokes in VB.net at this
line.

container.Filter = Array("Computer")

From some research I have found that this needs a variant array which
seems to be a problem in VB.net.

I wasn't able to test it:

dim filter as string()={"Computer"}

container.Filter = filter

- or -

container.Filter = new string(){"Computer"}

Here is the code above the problem line.
Dim container As IADsContainer

container = GetObject("WinNT://" & containername)

container.Filter = Array("Computer")

Any help would be appreciated.

Have you already had a look at the System.DirectoryServices.ActiveDirectory
namespace?


Armin
 
A

Armin Zingler

Ty said:
Hello all I am trying to port over an application that interacts with
Active Directory which worked fine in VB6 but chokes in VB.net at this
line.

container.Filter = Array("Computer")

From some research I have found that this needs a variant array which
seems to be a problem in VB.net.

I wasn't able to test it:

dim filter as string()={"Computer"}

container.Filter = filter

- or -

container.Filter = new string(){"Computer"}

Here is the code above the problem line.
Dim container As IADsContainer

container = GetObject("WinNT://" & containername)

container.Filter = Array("Computer")

Any help would be appreciated.

Have you already had a look at the System.DirectoryServices.ActiveDirectory
namespace?


Armin
 
M

Mike

Ty said:
Hello all I am trying to port over an application that interacts with
Active Directory which worked fine in VB6 but chokes in VB.net at this
line.

container.Filter = Array("Computer")

From some research I have found that this needs a variant array which
seems to be a problem in VB.net.

Yes, direct support for VARIANT type have been dropped.
Here is the code above the problem line.
Dim container As IADsContainer

container = GetObject("WinNT://" & containername)

container.Filter = Array("Computer")

Any help would be appreciated.

It would be surprising if MS does not add a .NET assembly for Active
Directory support. Let me do a google for:

MSDN VB.NET Active Directory

Yes, there is over 1 million hits on this and seems to be an elegant
solution. I think these may be useful:

Searching Active Directory with .NET (Visual Studio 2005) (VIDEO)
http://channel9.msdn.com/posts/RobertShelton/Searching-Active-Directory-with-NET-Visual-Studio-2005/

Active Directory in VB.NET - Get LDAP Users & Groups
http://www.freevbcode.com/ShowCode.asp?ID=8169

--
 
M

Mike

Ty said:
Hello all I am trying to port over an application that interacts with
Active Directory which worked fine in VB6 but chokes in VB.net at this
line.

container.Filter = Array("Computer")

From some research I have found that this needs a variant array which
seems to be a problem in VB.net.

Yes, direct support for VARIANT type have been dropped.
Here is the code above the problem line.
Dim container As IADsContainer

container = GetObject("WinNT://" & containername)

container.Filter = Array("Computer")

Any help would be appreciated.

It would be surprising if MS does not add a .NET assembly for Active
Directory support. Let me do a google for:

MSDN VB.NET Active Directory

Yes, there is over 1 million hits on this and seems to be an elegant
solution. I think these may be useful:

Searching Active Directory with .NET (Visual Studio 2005) (VIDEO)
http://channel9.msdn.com/posts/RobertShelton/Searching-Active-Directory-with-NET-Visual-Studio-2005/

Active Directory in VB.NET - Get LDAP Users & Groups
http://www.freevbcode.com/ShowCode.asp?ID=8169

--
 
C

Cor Ligthert[MVP]

Ty,

Can you make of that Array simple something as

dim theContainerArray[] as object

Array is a reserved word in Visual Basic Net.

Cor
 
C

Cor Ligthert[MVP]

Ty,

Can you make of that Array simple something as

dim theContainerArray[] as object

Array is a reserved word in Visual Basic Net.

Cor
 
M

Michel Posseth [MCP]

And on forehand one litle tip dispose every directorysearcher object as
otherwise you run out of ram and your prog will become terrible slow (
because of paging )
the directory searcher objects must be explicitly closed and disposed off ,
if you forget it it will hit you :)


HTH

Michel
 
M

Michel Posseth [MCP]

And on forehand one litle tip dispose every directorysearcher object as
otherwise you run out of ram and your prog will become terrible slow (
because of paging )
the directory searcher objects must be explicitly closed and disposed off ,
if you forget it it will hit you :)


HTH

Michel
 
T

Ty

Yes, direct support for VARIANT type have been dropped.





It would be surprising if MS does not add a .NET assembly for Active
Directory support.  Let me do a google for:

     MSDN VB.NET Active Directory

Yes, there is over 1 million hits on this and seems to be an elegant
solution.  I think these may be useful:

Searching Active Directory with .NET (Visual Studio 2005) (VIDEO)http://channel9.msdn.com/posts/RobertShelton/Searching-Active-Directo...

Active Directory in VB.NET - Get LDAP Users & Groupshttp://www.freevbcode..com/ShowCode.asp?ID=8169

--

Mike,

Thank you your post helped tremendously. I used this link and although
the video is not longer available the code had be up and running with
hardly any screaming and yelling :)

Searching Active Directory with .NET (Visual Studio 2005) (VIDEO)
http://channel9.msdn.com/posts/RobertShelton/Searching-Active-Directo...

Ty
 
T

Ty

Yes, direct support for VARIANT type have been dropped.





It would be surprising if MS does not add a .NET assembly for Active
Directory support.  Let me do a google for:

     MSDN VB.NET Active Directory

Yes, there is over 1 million hits on this and seems to be an elegant
solution.  I think these may be useful:

Searching Active Directory with .NET (Visual Studio 2005) (VIDEO)http://channel9.msdn.com/posts/RobertShelton/Searching-Active-Directo...

Active Directory in VB.NET - Get LDAP Users & Groupshttp://www.freevbcode..com/ShowCode.asp?ID=8169

--

Mike,

Thank you your post helped tremendously. I used this link and although
the video is not longer available the code had be up and running with
hardly any screaming and yelling :)

Searching Active Directory with .NET (Visual Studio 2005) (VIDEO)
http://channel9.msdn.com/posts/RobertShelton/Searching-Active-Directo...

Ty
 
T

Ty

Mike,

Thank you your post helped tremendously. I used this link and although
the video is not longer available the code had be up and running with
hardly any screaming and yelling :)

Searching Active Directory with .NET (Visual Studio 2005) (VIDEO)http://channel9.msdn.com/posts/RobertShelton/Searching-Active-Directo...

Ty- Hide quoted text -

- Show quoted text -

Just for anyone out there looking this worked great for me.

Dim root As String
root = "LDAP://OU=LHF Computers,DC=YOURDOMAIN,DC=.com"
Dim adrootObject As New DirectoryEntry(root)



'***********************************Computers****************************************

For Each childrenObjects As DirectoryEntry In
adrootObject.Children
' FSOfile.WriteLine computer.name
If Not childrenObjects.Properties("CN").Value = Nothing
Then
ListBox1.Items.Add(childrenObjects.Properties
("CN").Value)
End If
Next

Ty
 
T

Ty

Mike,

Thank you your post helped tremendously. I used this link and although
the video is not longer available the code had be up and running with
hardly any screaming and yelling :)

Searching Active Directory with .NET (Visual Studio 2005) (VIDEO)http://channel9.msdn.com/posts/RobertShelton/Searching-Active-Directo...

Ty- Hide quoted text -

- Show quoted text -

Just for anyone out there looking this worked great for me.

Dim root As String
root = "LDAP://OU=LHF Computers,DC=YOURDOMAIN,DC=.com"
Dim adrootObject As New DirectoryEntry(root)



'***********************************Computers****************************************

For Each childrenObjects As DirectoryEntry In
adrootObject.Children
' FSOfile.WriteLine computer.name
If Not childrenObjects.Properties("CN").Value = Nothing
Then
ListBox1.Items.Add(childrenObjects.Properties
("CN").Value)
End If
Next

Ty
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top