Results 1 to 4 of 4
  1. #1
    bignate is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2013
    Posts
    47

    Question List of all users from active directory

    Hi

    I would like to get a list of all the users in the active directory and put them in a combo box. Does anyone know how to do this?
    I would like it to show there CN name



    Thanks

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Pulled this from the depths of my swiss cheese mind....



    pkstormy posted a zip of AD code in the code-repository section of this forum on 08-28-2010.

    The posting name is "Active Directory coding"
    https://www.accessforums.net/code-re...ding-7691.html

  3. #3
    bignate is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2013
    Posts
    47
    Thank you for putting me in the right direction.

    A user called Galaxiom gave me this code and it does exactly what I want:

    Option Compare Database
    Option Explicit


    Public Function UserRecordset() As Object 'ADODB.Recordset


    Const adCmdText = 1
    Const adUseClient = 3


    Dim ADConn As Object ' ADODB.Connection
    Dim ADCommand As Object ' ADODB.Command
    Dim ADUser As Object ' ADODB.Command
    Dim DomainDN As String



    DomainDN = CreateObject("LDAP://rootDSE").Get("defaultNamingContext")

    Set ADConn = CreateObject("ADODB.Connection")
    With ADConn
    .CursorLocation = adUseClient
    .Provider = "ADsDSOObject"
    .Open "Active Directory Provider"
    End With

    Set ADCommand = CreateObject("ADODB.Command")
    With ADCommand
    .ActiveConnection = ADConn
    .CommandType = adCmdText
    .CommandText = "SELECT CN FROM 'LDAP://" & DomainDN & "' WHERE objectCategory='User' AND CN<>'IWAM_*' AND CN<>'IUSR_*' ORDER BY CN"
    End With

    Set ADUser = ADCommand.Execute
    Set ADUser.ActiveConnection = Nothing
    Set UserRecordset = ADUser

    ADConn.Close

    Set ADConn = Nothing
    Set ADCommand = Nothing




    End Function


    You can then make this module the record set for a combo box

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    I like it. One connection, a couple commands, and a string.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Active Directory & Access 2010: Importing Users
    By royarellano in forum Access
    Replies: 0
    Last Post: 12-08-2011, 02:32 AM
  2. MS Active Directory
    By pkelly in forum Access
    Replies: 9
    Last Post: 10-21-2011, 08:26 AM
  3. access+Active directory
    By cpcp in forum Access
    Replies: 6
    Last Post: 11-15-2010, 02:30 AM
  4. Active Directory coding
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 08-28-2010, 08:33 PM
  5. Use form List Box to query Active Directory
    By grafiksinc in forum Forms
    Replies: 4
    Last Post: 12-02-2009, 11:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums