Home All Groups Group Topic Archive Search About

Re: Reading a list of users from XP

Author
2 Oct 2006 6:47 PM
BK
Are you using Active Directory?

Author
3 Oct 2006 3:04 PM
Sam Smith
Yes, I believe we are using Active Directory.  We have a Windows 2003
server.

Show quoteHide quote
"BK" <bkunn***@hotmail.com> wrote in message
news:1159814834.535305.33030@m7g2000cwm.googlegroups.com...
> Are you using Active Directory?
>
Author
3 Oct 2006 4:32 PM
BK
This is crude, but it should get you started.  This code will give you
all the users in AD:

        Console.WriteLine("** Listing Start")

        Dim oDirectoryEntry As DirectoryServices.DirectoryEntry = New
DirectoryEntry("LDAP://SomeDomainHere")
        Dim oDirectorySearcher As DirectorySearcher = New
DirectorySearcher(oDirectoryEntry)

        oDirectorySearcher.Filter = ("(ObjectClass=User)")
        Dim oResult As SearchResult = oDirectorySearcher.FindOne
        For Each oResult In oDirectorySearcher.FindAll
            Console.WriteLine(oResult.GetDirectoryEntry().Name)
        Next

        Console.WriteLine("Listing End **")
Author
3 Oct 2006 10:22 PM
Sam Smith
I copied the code into my project but my DirectoryServices are not defined.
How can I do that?  Do I need to import a namespace?  If so, which one?  I
ran through Imports system.  and couldn't find DirectoryServices.

Any help would be appreciated.


Show quoteHide quote
"BK" <bkunn***@hotmail.com> wrote in message
news:1159893158.440548.155250@i3g2000cwc.googlegroups.com...
> This is crude, but it should get you started.  This code will give you
> all the users in AD:
>
>        Console.WriteLine("** Listing Start")
>
>        Dim oDirectoryEntry As DirectoryServices.DirectoryEntry = New
> DirectoryEntry("LDAP://SomeDomainHere")
>        Dim oDirectorySearcher As DirectorySearcher = New
> DirectorySearcher(oDirectoryEntry)
>
>        oDirectorySearcher.Filter = ("(ObjectClass=User)")
>        Dim oResult As SearchResult = oDirectorySearcher.FindOne
>        For Each oResult In oDirectorySearcher.FindAll
>            Console.WriteLine(oResult.GetDirectoryEntry().Name)
>        Next
>
>        Console.WriteLine("Listing End **")
>
Author
4 Oct 2006 11:57 AM
BK
> I copied the code into my project but my DirectoryServices are not defined.
> How can I do that?  Do I need to import a namespace?  If so, which one?  I
> ran through Imports system.  and couldn't find DirectoryServices.

Yep...

Imports System.DirectoryServices
Author
4 Oct 2006 2:13 PM
Sam Smith
There is no System.DirectoryServices when I look at intellisense.  Is there
something else to import first?

VS 2005   VB.NET


Show quoteHide quote
"BK" <bkunn***@hotmail.com> wrote in message
news:1159963025.181238.283280@k70g2000cwa.googlegroups.com...
>> I copied the code into my project but my DirectoryServices are not
>> defined.
>> How can I do that?  Do I need to import a namespace?  If so, which one?
>> I
>> ran through Imports system.  and couldn't find DirectoryServices.
>
> Yep...
>
> Imports System.DirectoryServices
>
Author
4 Oct 2006 7:37 PM
The Grim Reaper
Add a reference to System.DirectoryServices in the My Project thingammybob.
It's not referenced by default.
__________________________
The Reaper

Show quoteHide quote
"Sam Smith" <s**@yada.com> wrote in message
news:u690R975GHA.3808@TK2MSFTNGP06.phx.gbl...
> There is no System.DirectoryServices when I look at intellisense.  Is
> there something else to import first?
>
> VS 2005   VB.NET
>
>
> "BK" <bkunn***@hotmail.com> wrote in message
> news:1159963025.181238.283280@k70g2000cwa.googlegroups.com...
>>> I copied the code into my project but my DirectoryServices are not
>>> defined.
>>> How can I do that?  Do I need to import a namespace?  If so, which one?
>>> I
>>> ran through Imports system.  and couldn't find DirectoryServices.
>>
>> Yep...
>>
>> Imports System.DirectoryServices
>>
>
>
Author
5 Oct 2006 3:15 PM
Sam Smith
I added the reference to DirectoryServices into my project and it now works.
Thanks for the tip.


Show quoteHide quote
"The Grim Reaper" <grim_rea***@REMOVEbtopenworld.com> wrote in message
news:tKGdnVkmVL3zkLnYRVnyrg@bt.com...
> Add a reference to System.DirectoryServices in the My Project
> thingammybob.
> It's not referenced by default.
> __________________________
> The Reaper
>
> "Sam Smith" <s**@yada.com> wrote in message
> news:u690R975GHA.3808@TK2MSFTNGP06.phx.gbl...
>> There is no System.DirectoryServices when I look at intellisense.  Is
>> there something else to import first?
>>
>> VS 2005   VB.NET
>>
>>
>> "BK" <bkunn***@hotmail.com> wrote in message
>> news:1159963025.181238.283280@k70g2000cwa.googlegroups.com...
>>>> I copied the code into my project but my DirectoryServices are not
>>>> defined.
>>>> How can I do that?  Do I need to import a namespace?  If so, which one?
>>>> I
>>>> ran through Imports system.  and couldn't find DirectoryServices.
>>>
>>> Yep...
>>>
>>> Imports System.DirectoryServices
>>>
>>
>>
>
>