Listing users of a database

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bill..AT..piperb.freeserve.co.uk

    #1

    Listing users of a database

    I have used code from MS 198755 to create a module that lists current
    users of the database. Works fine as long as db isnot password
    potected. How do I adapt code to enter password?

    This is code:

    Sub ShowUserRosterM ultipleUsers()
    Dim cn As New ADODB.Connectio n
    Dim cn2 As New ADODB.Connectio n
    Dim rs As New ADODB.Recordset
    Dim i, j As Long

    cn.Provider = "Microsoft.Jet. OLEDB.4.0"
    cn.Open "Data Source=c:\North wind.mdb"

    cn2.Open "Provider=Micro soft.Jet.OLEDB. 4.0;" _
    & "Data Source=c:\North wind.mdb"

    ' The user roster is exposed as a provider-specific schema rowset
    ' in the Jet 4 OLE DB provider. You have to use a GUID to
    ' reference the schema, as provider-specific schemas are not
    ' listed in ADO's type library for schema rowsets

    Set rs = cn.OpenSchema(a dSchemaProvider Specific, _
    , "{947bb102-5d43-11d1-bdbf-00c04fb92675}")

    'Output the list of all users in the current database.

    Debug.Print rs.Fields(0).Na me, "", rs.Fields(1).Na me, _
    "", rs.Fields(2).Na me, rs.Fields(3).Na me

    While Not rs.EOF
    Debug.Print rs.Fields(0), rs.Fields(1), _
    rs.Fields(2), rs.Fields(3)
    rs.MoveNext
    Wend

    End Sub

    Many thanks for any help

  • Tom van Stiphout

    #2
    Re: Listing users of a database

    On 3 Nov 2005 13:10:18 -0800, "bill..AT..pipe rb.freeserve.co .uk"
    <bill@piperb.fr eeserve.co.uk> wrote:

    You put the password as part of the connect string in the Open method.
    See connectionstrin gs.com for examples for that.

    -Tom.

    [color=blue]
    >I have used code from MS 198755 to create a module that lists current
    >users of the database. Works fine as long as db isnot password
    >potected. How do I adapt code to enter password?
    >
    >This is code:
    >
    >Sub ShowUserRosterM ultipleUsers()
    > Dim cn As New ADODB.Connectio n
    > Dim cn2 As New ADODB.Connectio n
    > Dim rs As New ADODB.Recordset
    > Dim i, j As Long
    >
    > cn.Provider = "Microsoft.Jet. OLEDB.4.0"
    > cn.Open "Data Source=c:\North wind.mdb"
    >
    > cn2.Open "Provider=Micro soft.Jet.OLEDB. 4.0;" _
    > & "Data Source=c:\North wind.mdb"
    >
    > ' The user roster is exposed as a provider-specific schema rowset
    > ' in the Jet 4 OLE DB provider. You have to use a GUID to
    > ' reference the schema, as provider-specific schemas are not
    > ' listed in ADO's type library for schema rowsets
    >
    > Set rs = cn.OpenSchema(a dSchemaProvider Specific, _
    > , "{947bb102-5d43-11d1-bdbf-00c04fb92675}")
    >
    > 'Output the list of all users in the current database.
    >
    > Debug.Print rs.Fields(0).Na me, "", rs.Fields(1).Na me, _
    > "", rs.Fields(2).Na me, rs.Fields(3).Na me
    >
    > While Not rs.EOF
    > Debug.Print rs.Fields(0), rs.Fields(1), _
    > rs.Fields(2), rs.Fields(3)
    > rs.MoveNext
    > Wend
    >
    >End Sub
    >
    >Many thanks for any help[/color]

    Comment

    • bill..AT..piperb.freeserve.co.uk

      #3
      Re: Listing users of a database

      Thanks Tom but sorry to be thick, I do not seem to be able to get it to
      work.

      Should I put
      cn.Open "Data Source=c:\North wind.mdb,,passw ord"
      or
      cn.Open "Data Source=c:\North wind.mdb"; ; "password"
      or
      cn.Open "Data Source=c:\North wind.mdb"; ; pwd = "password"
      or........
      And do I need to put the same bit into the other data source line?

      As you can tell I am far from expert!
      Cheers for any help.
      Bill
      Tom van Stiphout wrote:[color=blue]
      > On 3 Nov 2005 13:10:18 -0800, "bill..AT..pipe rb.freeserve.co .uk"
      > <bill@piperb.fr eeserve.co.uk> wrote:
      >
      > You put the password as part of the connect string in the Open method.
      > See connectionstrin gs.com for examples for that.
      >
      > -Tom.
      >
      >[color=green]
      > >I have used code from MS 198755 to create a module that lists current
      > >users of the database. Works fine as long as db isnot password
      > >potected. How do I adapt code to enter password?
      > >
      > >This is code:
      > >
      > >Sub ShowUserRosterM ultipleUsers()
      > > Dim cn As New ADODB.Connectio n
      > > Dim cn2 As New ADODB.Connectio n
      > > Dim rs As New ADODB.Recordset
      > > Dim i, j As Long
      > >
      > > cn.Provider = "Microsoft.Jet. OLEDB.4.0"
      > > cn.Open "Data Source=c:\North wind.mdb"
      > >
      > > cn2.Open "Provider=Micro soft.Jet.OLEDB. 4.0;" _
      > > & "Data Source=c:\North wind.mdb"
      > >
      > > ' The user roster is exposed as a provider-specific schema rowset
      > > ' in the Jet 4 OLE DB provider. You have to use a GUID to
      > > ' reference the schema, as provider-specific schemas are not
      > > ' listed in ADO's type library for schema rowsets
      > >
      > > Set rs = cn.OpenSchema(a dSchemaProvider Specific, _
      > > , "{947bb102-5d43-11d1-bdbf-00c04fb92675}")
      > >
      > > 'Output the list of all users in the current database.
      > >
      > > Debug.Print rs.Fields(0).Na me, "", rs.Fields(1).Na me, _
      > > "", rs.Fields(2).Na me, rs.Fields(3).Na me
      > >
      > > While Not rs.EOF
      > > Debug.Print rs.Fields(0), rs.Fields(1), _
      > > rs.Fields(2), rs.Fields(3)
      > > rs.MoveNext
      > > Wend
      > >
      > >End Sub
      > >
      > >Many thanks for any help[/color][/color]

      Comment

      • Tom van Stiphout

        #4
        Re: Listing users of a database

        On 4 Nov 2005 13:06:14 -0800, "bill..AT..pipe rb.freeserve.co .uk"
        <bill@piperb.fr eeserve.co.uk> wrote:

        cn.Open "Provider=Micro soft.Jet.OLEDB. 4.0;Data
        Source=c:\North wind.mdb;Jet OLEDB:Database
        Password=SomeSe cretPassword;"

        In your code sample you are not using cn2. Comment out all lines with
        cn2 and you'd still be OK.

        -Tom.

        [color=blue]
        >Thanks Tom but sorry to be thick, I do not seem to be able to get it to
        >work.
        >
        >Should I put
        >cn.Open "Data Source=c:\North wind.mdb,,passw ord"
        >or
        >cn.Open "Data Source=c:\North wind.mdb"; ; "password"
        >or
        >cn.Open "Data Source=c:\North wind.mdb"; ; pwd = "password"
        >or........
        >And do I need to put the same bit into the other data source line?
        >
        >As you can tell I am far from expert!
        >Cheers for any help.
        >Bill
        >Tom van Stiphout wrote:[color=green]
        >> On 3 Nov 2005 13:10:18 -0800, "bill..AT..pipe rb.freeserve.co .uk"
        >> <bill@piperb.fr eeserve.co.uk> wrote:
        >>
        >> You put the password as part of the connect string in the Open method.
        >> See connectionstrin gs.com for examples for that.
        >>
        >> -Tom.
        >>
        >>[color=darkred]
        >> >I have used code from MS 198755 to create a module that lists current
        >> >users of the database. Works fine as long as db isnot password
        >> >potected. How do I adapt code to enter password?
        >> >
        >> >This is code:
        >> >
        >> >Sub ShowUserRosterM ultipleUsers()
        >> > Dim cn As New ADODB.Connectio n
        >> > Dim cn2 As New ADODB.Connectio n
        >> > Dim rs As New ADODB.Recordset
        >> > Dim i, j As Long
        >> >
        >> > cn.Provider = "Microsoft.Jet. OLEDB.4.0"
        >> > cn.Open "Data Source=c:\North wind.mdb"
        >> >
        >> > cn2.Open "Provider=Micro soft.Jet.OLEDB. 4.0;" _
        >> > & "Data Source=c:\North wind.mdb"
        >> >
        >> > ' The user roster is exposed as a provider-specific schema rowset
        >> > ' in the Jet 4 OLE DB provider. You have to use a GUID to
        >> > ' reference the schema, as provider-specific schemas are not
        >> > ' listed in ADO's type library for schema rowsets
        >> >
        >> > Set rs = cn.OpenSchema(a dSchemaProvider Specific, _
        >> > , "{947bb102-5d43-11d1-bdbf-00c04fb92675}")
        >> >
        >> > 'Output the list of all users in the current database.
        >> >
        >> > Debug.Print rs.Fields(0).Na me, "", rs.Fields(1).Na me, _
        >> > "", rs.Fields(2).Na me, rs.Fields(3).Na me
        >> >
        >> > While Not rs.EOF
        >> > Debug.Print rs.Fields(0), rs.Fields(1), _
        >> > rs.Fields(2), rs.Fields(3)
        >> > rs.MoveNext
        >> > Wend
        >> >
        >> >End Sub
        >> >
        >> >Many thanks for any help[/color][/color][/color]

        Comment

        • bill..AT..piperb.freeserve.co.uk

          #5
          Re: Listing users of a database

          Thanks Tom. I will give it a whirl!

          Bill

          Comment

          Working...