|
Home > Archive > MS Access Multiuser > March 2006 > Code to Choose Multi/Single User
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Code to Choose Multi/Single User
|
|
| Russ Scribner 2006-03-07, 8:25 pm |
| Hello,
I am currently working on an application that uses a license key (made up by
me) to determine whether the user has rights for a single user or a
multi-user license. I have split the database and would like to allow the
user to put the BE on their server while their FE is on their workstation.
The question is how I can keep the user from connecting to the BE with
multiple FE on seperate workstations if they only have a license to connect
with one FE.
My idea is that I could have the program check their license key and if they
only have rights to open the database with a single workstation I could
change their logon to exclusive. In my mind that would keep other FE from
connecting. Is there a way to do that programatically? Any other ideas?
Thanks...
--
Russ Scribner
| |
| Jesper F 2006-03-07, 8:25 pm |
| > I am currently working on an application that uses a license key (made up
> by
> me) to determine whether the user has rights for a single user or a
> multi-user license. I have split the database and would like to allow the
> user to put the BE on their server while their FE is on their workstation.
> The question is how I can keep the user from connecting to the BE with
> multiple FE on seperate workstations if they only have a license to
> connect
> with one FE.
>
> My idea is that I could have the program check their license key and if
> they
> only have rights to open the database with a single workstation I could
> change their logon to exclusive. In my mind that would keep other FE from
> connecting. Is there a way to do that programatically? Any other ideas?
Maybe you could check to see if other are logged into the BE when a
workstations tries to connect.
If others are using the BE you can deny access.
There are ways to get a list of the users that are using a the BE.
Maybe that's a way to go.
Jesper Fjølner
| |
| Russ Scribner 2006-03-07, 8:25 pm |
| Thanks Jesper,
I'm looking into using the WhosOn() function that I found on several
websites to look at how many are logged into the ldb on the BE. Is that what
you were referring to?
--
Russ Scribner
"Jesper F" wrote:
>
> Maybe you could check to see if other are logged into the BE when a
> workstations tries to connect.
> If others are using the BE you can deny access.
> There are ways to get a list of the users that are using a the BE.
> Maybe that's a way to go.
>
>
> Jesper Fjølner
>
>
>
| |
| Graham R Seach 2006-03-09, 7:27 am |
| Russ,
I haven't tested this against a multiuser database, but you could try
setting the following property:
CurrentProject.Connection.Properties("Jet OLEDB:Connection Control")
Setting it to 1 prevents more than 1 user from connecting to the database.
Setting it to 2, alows multiple users to connect.
Use something like the following, called from the AutoExec macro:
Public Function VerifyLicense()
If IsMultiUser Then
CurrentProject.Connection.Properties("Jet OLEDB:Connection Control")
= 2
Else
CurrentProject.Connection.Properties("Jet OLEDB:Connection Control")
= 1
End If
End Sub
Like I said, I've never tried this on a multiuser database. If it works,
great, if not, no harm done (provided you set the property back to 2).
Failing that, you can use the following (which is adapted from code written
(I think) by Dev Ashish).
Private Const JET_SCHEMA_USERROSTE
R =
"{947bb102-5d43-11d1-bdbf-00c0_4fb92675}"
Public Function LimitUsers(iNumber As Integer) As Boolean
'Compare the number of database users to a provided number,
'and if greater, shutdown the current database instance.
Dim rs As ADODB.Recordset
Dim iCtr As Integer
'Make sure the programmer allows at least one user.
If iNumber = 1 Then iNumber = 2
'Open the roster.
Set rs = CurrentProject.Connection.Open_Schema( _
adSchemaProviderSpec
ific, , JET_SCHEMA_USERROSTE
R)
'rs.RecordCount doesn't work reliably here, so we need to cycle
'through the recordset to count the number of users.
Do While Not rs.EOF
iCtr = iCtr + 1
'If the number of users exceeds iNumber, then shutdown the
'current database instance.
If iCtr > iNumber Then GoTo Proc_Shutdown
rs.MoveNext
Loop
'Clean up
rs.Close
Set rs = Nothing
Exit Function
Proc_Shutdown:
'Clean up before shutting down the current database instance.
rs.Close
Set rs = Nothing
Application.Quit
End Function
Regards,
Graham R Seach
Microsoft Access MVP
Canberra, Australia
---------------------------
"Russ Scribner" < RussScribner@discuss
ions.microsoft.com> wrote in message
news:6B09D025-E6F1-4EFD-AB23- 52293182443E@microso
ft.com...
> Hello,
>
> I am currently working on an application that uses a license key (made up
> by
> me) to determine whether the user has rights for a single user or a
> multi-user license. I have split the database and would like to allow the
> user to put the BE on their server while their FE is on their workstation.
> The question is how I can keep the user from connecting to the BE with
> multiple FE on seperate workstations if they only have a license to
> connect
> with one FE.
>
> My idea is that I could have the program check their license key and if
> they
> only have rights to open the database with a single workstation I could
> change their logon to exclusive. In my mind that would keep other FE from
> connecting. Is there a way to do that programatically? Any other ideas?
>
> Thanks...
> --
> Russ Scribner
| |
| Russ Scribner 2006-03-09, 8:25 pm |
| Thanks for the good ideas Graham. I think I've got it solved with the
WhosOn() function - but your ideas would probably have been simpler...
Thanks again...
--
Russ Scribner
"Graham R Seach" wrote:
> Russ,
>
> I haven't tested this against a multiuser database, but you could try
> setting the following property:
> CurrentProject.Connection.Properties("Jet OLEDB:Connection Control")
>
> Setting it to 1 prevents more than 1 user from connecting to the database.
> Setting it to 2, alows multiple users to connect.
>
> Use something like the following, called from the AutoExec macro:
>
> Public Function VerifyLicense()
> If IsMultiUser Then
> CurrentProject.Connection.Properties("Jet OLEDB:Connection Control")
> = 2
> Else
> CurrentProject.Connection.Properties("Jet OLEDB:Connection Control")
> = 1
> End If
> End Sub
>
> Like I said, I've never tried this on a multiuser database. If it works,
> great, if not, no harm done (provided you set the property back to 2).
>
> Failing that, you can use the following (which is adapted from code written
> (I think) by Dev Ashish).
>
> Private Const JET_SCHEMA_USERROSTE
R =
> "{947bb102-5d43-11d1-bdbf-00c0Â_4fb92675}"
>
> Public Function LimitUsers(iNumber As Integer) As Boolean
> 'Compare the number of database users to a provided number,
> 'and if greater, shutdown the current database instance.
>
> Dim rs As ADODB.Recordset
> Dim iCtr As Integer
>
> 'Make sure the programmer allows at least one user.
> If iNumber = 1 Then iNumber = 2
>
> 'Open the roster.
> Set rs = CurrentProject.Connection.OpenÂ_Schema( _
> adSchemaProviderSpec
ific, , JET_SCHEMA_USERROSTE
R)
>
> 'rs.RecordCount doesn't work reliably here, so we need to cycle
> 'through the recordset to count the number of users.
> Do While Not rs.EOF
> iCtr = iCtr + 1
> 'If the number of users exceeds iNumber, then shutdown the
> 'current database instance.
> If iCtr > iNumber Then GoTo Proc_Shutdown
> rs.MoveNext
> Loop
>
> 'Clean up
> rs.Close
> Set rs = Nothing
> Exit Function
>
> Proc_Shutdown:
> 'Clean up before shutting down the current database instance.
> rs.Close
> Set rs = Nothing
> Application.Quit
> End Function
>
> Regards,
> Graham R Seach
> Microsoft Access MVP
> Canberra, Australia
> ---------------------------
>
> "Russ Scribner" < RussScribner@discuss
ions.microsoft.com> wrote in message
> news:6B09D025-E6F1-4EFD-AB23- 52293182443E@microso
ft.com...
>
>
>
|
|
|
|
|