Results 1 to 8 of 8

Thread: Macro not working for fetching data from Active Directory

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #8
    VBAX Regular
    Joined
    May 2018
    Location
    Sydney
    Posts
    57
    Location
    To use the ADODB.Connection object in the code, you can add the following line of code at the beginning of the code, after the declaration of the variables:



    Dim adoconn As New ADODB.Conn
    ection


    This will create a new instance of the ADODB.Connection object, which can be used to establish a connection to a data source using ActiveX Data Objects (ADO). You can then use the Open method of the adoconn object to open a connection to the desired data source.


    For example, to open a connection to a Microsoft SQL Server database, you can use the following code:


    adoconn.Open "Provider=SQLOLEDB;Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;"
    Once the connection is open, you can use the Execute method of the adoconn object to execute SQL queries or stored procedures on the data source.


    However, it is worth noting that the code you provided does not appear to use a database or any other data source that would require a connection. Instead, it appears to be using the GetObject function to retrieve information about an Active Directory user, based on the user's signum. In that case, you do not need to use the ADODB.Connection object.


    As for the issue with the idapstr line, it is difficult to say without more information. It is possible that there is a problem with the data being passed to the GetObject function, or with the way the ldapstr variable is constructed. I would recommend checking the values of the signum and other variables that are used to construct the ldapstr variable, to make sure they are correct and valid. You may also want to try using the Debug.Print statement to print the value of the ldapstr variable, to see if it is correct.
    Last edited by Aussiebear; 04-15-2025 at 04:27 AM.
    If you only ever do what you can , you'll only ever be what you are.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •