Home All Groups Group Topic Archive Search About

Synchronizing secured replicas

Author
27 Apr 2009 2:30 PM
RickW
I have replicated the back end database of a split Access 2003 application. 
User level security is also set with full permission granted on all
non-system tables in all replicas and the front end linked tables.

I have non-replicated front ends from which it needs to be possible to
synchronise the linked back-end replica with the main hub back-end replica. 
I am using JRO but I'm getting the following permissions error when the
ActiveConnection property is being set to the linked backend mdb

Sub Synchronise(strThisReplica As String, strOtherReplica As String)
    Dim repReplica As New JRO.Replica

    repReplica.ActiveConnection = strThisReplica            ERROR HERE

    repReplica.Synchronize strOtherReplica, jrSyncTypeImpExp, jrSyncModeDirect
    Set repReplica = Nothing
End Sub

Error: -2147467259  You do not have the necessary permissions to use the
'...path/filename of linked backend replica mdb...' object.  Have your system
administrator or the person who created this object establish the appropriate
permissions for you.

I am otherwise able to use the front end for creating and amending records
without any permissions problem.  Similarly, I can synchronise the replicas
successfully using the Tools > Replication > Synchronise now menu command so
I'm mystified as to why there should be a problem running the code below to
synchronise replica backends.

Hoping someone can help!
Rick

Author
27 Apr 2009 7:05 PM
David W. Fenton
=?Utf-8?B?Umlja1c=?= <Ri***@discussions.microsoft.com> wrote in
news:3F74D85D-5462-4EB3-8806-8937BCAD12CD@microsoft.com:

> I have replicated the back end database of a split Access 2003
> application.  User level security is also set with full permission
> granted on all non-system tables in all replicas and the front end
> linked tables.

ULS works the same with replication as it does without it. To open a
back end in code, you have to supply credentials for a replica just
as you would for a non-replica.

> I have non-replicated front ends from which it needs to be
> possible to synchronise the linked back-end replica with the main
> hub back-end replica.  I am using JRO but I'm getting the
> following permissions error when the ActiveConnection property is
> being set to the linked backend mdb

I don't use JRO because there is no valid reason for JRO to exist in
the first place, but it does seem to me that your code has problems.
I would think that .ActiveConnection would return a connection
object, and not be settable with a string.

> Sub Synchronise(strThisReplica As String, strOtherReplica As
> String)
>     Dim repReplica As New JRO.Replica
>    
>     repReplica.ActiveConnection = strThisReplica            ERROR
>     HERE

Just looking around, I see code like this, which looks very ADO-like
(as to be expected):

  Dim conn As New ADODB.Connection
  Dim repRW As New JRO.Replica

  conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data source=C:\demo\NWindRW.mdb;"
  repRW.ActiveConnection = conn

This allows you to control the connection, and the arguments for the
connection string will include the security settings (dunno if you
have to include the workgroup file as well).

Now, I do see other code examples that you can actually assign a
string value to .ActiveConnection, but since there it takes no other
arguments, there is no way to set the ULS settings. Now, if you were
using the CurrentProject.Connection object, that would be different
as you would then already be running in the appropriate security
context from your front end.

Assuming the file you're running the code in has linked tables that
point to the replica you want to use, perhaps you could just use:

  repReplica.ActiveConnection = CurrentProject.Connection

[]

> I am otherwise able to use the front end for creating and amending
> records without any permissions problem.  Similarly, I can
> synchronise the replicas successfully using the Tools >
> Replication > Synchronise now menu command so I'm mystified as to
> why there should be a problem running the code below to
> synchronise replica backends.

I don't know if I've managed to answer your question, since I'm
proposing alternatives for ADO and JRO, which I don't use at all (I
would always use DAO for these operations). But maybe it will point
you in the right direction.

--
David W. Fenton                  http://www.dfenton.com/
usenet at dfenton dot com    http://www.dfenton.com/DFA/
Are all your drivers up to date? click for free checkup

Author
27 Apr 2009 9:29 PM
RickW
Thanks for your suggestions and I will have a closer look at them.  However,
the JRO method I have used does work until I secure the backend replicas. 
Furthermore, I got the code from the msdn article "Implementing Database
Replication with JRO" at
http://msdn.microsoft.com/en-us/library/aa140026.aspx  This is why I first
posted the question in this forum.

Show quoteHide quote
"David W. Fenton" wrote:

> =?Utf-8?B?Umlja1c=?= <Ri***@discussions.microsoft.com> wrote in
> news:3F74D85D-5462-4EB3-8806-8937BCAD12CD@microsoft.com:
>
> > I have replicated the back end database of a split Access 2003
> > application.  User level security is also set with full permission
> > granted on all non-system tables in all replicas and the front end
> > linked tables.
>
> ULS works the same with replication as it does without it. To open a
> back end in code, you have to supply credentials for a replica just
> as you would for a non-replica.
>
> > I have non-replicated front ends from which it needs to be
> > possible to synchronise the linked back-end replica with the main
> > hub back-end replica.  I am using JRO but I'm getting the
> > following permissions error when the ActiveConnection property is
> > being set to the linked backend mdb
>
> I don't use JRO because there is no valid reason for JRO to exist in
> the first place, but it does seem to me that your code has problems.
> I would think that .ActiveConnection would return a connection
> object, and not be settable with a string.
>
> > Sub Synchronise(strThisReplica As String, strOtherReplica As
> > String)
> >     Dim repReplica As New JRO.Replica
> >    
> >     repReplica.ActiveConnection = strThisReplica            ERROR
> >     HERE
>
> Just looking around, I see code like this, which looks very ADO-like
> (as to be expected):
>
>   Dim conn As New ADODB.Connection
>   Dim repRW As New JRO.Replica
>
>   conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
>         "Data source=C:\demo\NWindRW.mdb;"
>   repRW.ActiveConnection = conn
>
> This allows you to control the connection, and the arguments for the
> connection string will include the security settings (dunno if you
> have to include the workgroup file as well).
>
> Now, I do see other code examples that you can actually assign a
> string value to .ActiveConnection, but since there it takes no other
> arguments, there is no way to set the ULS settings. Now, if you were
> using the CurrentProject.Connection object, that would be different
> as you would then already be running in the appropriate security
> context from your front end.
>
> Assuming the file you're running the code in has linked tables that
> point to the replica you want to use, perhaps you could just use:
>
>   repReplica.ActiveConnection = CurrentProject.Connection
>
> []
>
> > I am otherwise able to use the front end for creating and amending
> > records without any permissions problem.  Similarly, I can
> > synchronise the replicas successfully using the Tools >
> > Replication > Synchronise now menu command so I'm mystified as to
> > why there should be a problem running the code below to
> > synchronise replica backends.
>
> I don't know if I've managed to answer your question, since I'm
> proposing alternatives for ADO and JRO, which I don't use at all (I
> would always use DAO for these operations). But maybe it will point
> you in the right direction.
>
> --
> David W. Fenton                  http://www.dfenton.com/
> usenet at dfenton dot com    http://www.dfenton.com/DFA/
>
Author
29 Apr 2009 7:42 PM
David W. Fenton
=?Utf-8?B?Umlja1c=?= <Ri***@discussions.microsoft.com> wrote in
news:F2FFF9CB-80D9-47B8-A1DB-BDDD948EF94F@microsoft.com:

> Thanks for your suggestions and I will have a closer look at them.
>  However, the JRO method I have used does work until I secure the
> backend replicas.  Furthermore, I got the code from the msdn
> article "Implementing Database Replication with JRO" at
> http://msdn.microsoft.com/en-us/library/aa140026.aspx  This is why
> I first posted the question in this forum.

And the reason it's not working is because there is no mechanism
with that method of using .ActiveConnection to supply the
username/password. Hence, you have to do it differently with a
secured back end.

It's the answer to your question. You don't have to like it, but it
*is* the answer.

--
David W. Fenton                  http://www.dfenton.com/
usenet at dfenton dot com    http://www.dfenton.com/DFA/
Author
29 Apr 2009 8:39 PM
RickW
Thanks very much for your initial advice.  I was convinced I had something
wrong with the permissions as I am not familiar with Access security, but I
did change my code as you suggested and ended up with a connection string in
which the user name, password and mdw file are all specified.  Its now
working just fine though I don't particularly like having to include the
password in code.  I don't think there is an alternative is there?

Rick

Show quoteHide quote
"David W. Fenton" wrote:

> =?Utf-8?B?Umlja1c=?= <Ri***@discussions.microsoft.com> wrote in
> news:F2FFF9CB-80D9-47B8-A1DB-BDDD948EF94F@microsoft.com:
>
> > Thanks for your suggestions and I will have a closer look at them.
> >  However, the JRO method I have used does work until I secure the
> > backend replicas.  Furthermore, I got the code from the msdn
> > article "Implementing Database Replication with JRO" at
> > http://msdn.microsoft.com/en-us/library/aa140026.aspx  This is why
> > I first posted the question in this forum.
>
> And the reason it's not working is because there is no mechanism
> with that method of using .ActiveConnection to supply the
> username/password. Hence, you have to do it differently with a
> secured back end.
>
> It's the answer to your question. You don't have to like it, but it
> *is* the answer.
>
> --
> David W. Fenton                  http://www.dfenton.com/
> usenet at dfenton dot com    http://www.dfenton.com/DFA/
>
Author
1 May 2009 2:17 AM
David W. Fenton
=?Utf-8?B?Umlja1c=?= <Ri***@discussions.microsoft.com> wrote in
news:460421B6-8BDF-45F8-8339-2A9584B604E6@microsoft.com:

> I was convinced I had something
> wrong with the permissions as I am not familiar with Access
> security, but I did change my code as you suggested and ended up
> with a connection string in which the user name, password and mdw
> file are all specified.  Its now working just fine though I don't
> particularly like having to include the password in code.  I don't
> think there is an alternative is there?

You need to encrypt your front end.

Also, you could make it dynamic by requesting it from the user.

--
David W. Fenton                  http://www.dfenton.com/
usenet at dfenton dot com    http://www.dfenton.com/DFA/

Bookmark and Share