Accessing Active Directory

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MIchele

    #1

    Accessing Active Directory

    Hi
    I want to access via VB.Net the active directory
    I want to list all the users and groups in AD and, if it's possible, also the exchange mailbox of each users..

    Anyone can help me? Please...

    Michele
  • Alex

    #2
    Re: Accessing Active Directory

    Check out the System.Director yServices Namespace

    "MIchele" <mmassari@omniw ay.sm> wrote in message
    news:BD8614B3-BED9-42C0-B2E7-D65E9A8BC3AC@mi crosoft.com...[color=blue]
    > Hi,
    > I want to access via VB.Net the active directory.
    > I want to list all the users and groups in AD and, if it's possible, also[/color]
    the exchange mailbox of each users...[color=blue]
    >
    > Anyone can help me? Please....
    >
    > Michele[/color]


    Comment

    • Marc Scheuner [MVP ADSI]

      #3
      Re: Accessing Active Directory

      >I want to access via VB.Net the active directory.[color=blue]
      >I want to list all the users and groups in AD and, if it's possible, also the exchange mailbox of each users...[/color]

      All users across all OU's in your AD ?? There could be many....

      THis is C# - should be easy to convert to VB.NET - you'll need to use
      the DirectorySearch er class:

      DirectorySearch er oSrch = new DirectorySearch er("");

      oSrch.Filter = "(&(objectClass =user)(objectCa tegory=user))";
      oSrch.SearchSco pe = SearchScope.Sub tree;

      oSrch.Propertie sToLoad.Add("gi venName");
      oSrch.Propertie sToLoad.Add("sn ");
      oSrch.Propertie sToLoad.Add("ma il");

      foreach(SearchR esult oRes in oSrch.FindAll() )
      {
      Console.WriteLi ne("User: " +
      oRes.Properties["givenName"].Value.ToString () + " " +
      oRes.Properties["sn"].Value.ToString () + " / E-Mail: " +
      oRes.Properties["mail"].Value.ToString ();
      }

      It searches the directory, load the "givenName" and "sn" (Surname") as
      well as "mail" (e-mail address) properties for the search results, and
      loops through the results.

      For groups, you'll just need to adjust the filter accordingly.

      Marc

      Comment

      • Evan Freeman[C++ Samuri]

        #4
        Re: Accessing Active Directory

        Here is your starting point:

        Dim enTry As DirectoryEntry = New DirectoryEntry( LDAP://<DomainNameHere >)
        Console.WriteLi ne("Active Directory Information")
        Console.WriteLi ne("=========== =============== =============== ==")
        For Each resEnt As DirectoryEntry In enTry.Children
        If (resEnt.SchemaC lassName().Equa ls("organizatio nalUnit")) Then
        Console.WriteLi ne(resEnt.Name. ToString())
        'Console.WriteL ine(resEnt.GetD irectoryEntry() .Path.ToString( ))
        'Console.WriteL ine(resEnt.GetD irectoryEntry() .NativeGuid.ToS tring())
        Console.WriteLi ne("=========== =============== =============== ==")
        Else
        Debug.WriteLine (resEnt.SchemaC lassName().ToSt ring())
        End If
        Next

        Don't forget a reference to the System.Director yServices namespace, and be sure to use your domain name in the code.

        -Enjoy!!

        -Evan


        "MIchele" <mmassari@omniw ay.sm> wrote in message news:BD8614B3-BED9-42C0-B2E7-D65E9A8BC3AC@mi crosoft.com...[color=blue]
        > Hi,
        > I want to access via VB.Net the active directory.
        > I want to list all the users and groups in AD and, if it's possible, also the exchange mailbox of each users...
        >
        > Anyone can help me? Please....
        >
        > Michele[/color]

        Comment

        Working...