Results 1 to 14 of 14
  1. #1
    Join Date
    Mar 2010
    Posts
    88

    Unanswered: How to check if this is Server or Client?

    I have a multiuser setup: one machine (the Server) holds the backend files, plus a copy of the client database for someone to use. I have several other machines with just a copy of the client database, linked to the backend files on the Server. This all works fine.

    However, I want some functions (eg managing backups) to be available only if you are sitting at the Server machine, not the client, so I need a function to test this. I'm frustratingly close to getting this working!

    - Each client database has a local settings table in which I can conveniently store an "Am I the Server?" flag, and I have all the necessary functions and logic to do the checking at the right time and set the flag
    - The local settings table also includes the paths to the backend database files

    My problem is - how does the client database tell whether it is the "Server" (connected to a local database) or "Client" (connected across a network). This needs to work across Win7, Vista and XP in any combination, and I can't be sure which drive letter will have been used for mapping the share.

    One thought was to read the beginning of the backend database file name, but it seems to be inconsistent as to whether it begins "\\" or "<driveletter>:". I could test to see if it begins with "C:" but that's just asking for trouble one day in the future when someone decides to install it on a D: drive.

    Any bright ideas out there?

    TIA.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    ...why go through all this pain
    bung all your server operations into a separate MDB, with whatever processes you need to do controlled by an autoexec macro, or called as a command line switch
    bung the new mdb into a windows scheduler job
    leave your front end clean and tidy so its the same froint end on every machine
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Mar 2010
    Posts
    88
    thanks for the response, but I'd rather not do that ... first, I'm trying to keep this as simple as possible from the outside, as the system needs to be installable by non-experts in other places (which is a good reason for keeping the number of DB files to a minimum).

    Plus, backup was only one example - some other stuff would be less easy to separate.

    I agree about only wanting one frontend, though - that's what I'm trying to achieve!

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so have a front end for users
    and an additional front end for admin

    OR

    place your admin code int he same front end, but protect it by security if only admins knwo the password to the server stuff then its left in one location

    the only other way I know woudl be to use an external settign (say writign to the registry.. however that could cause some AV's to get stroppy it may also be seen as 'poor form' by users of the software

    failing that a local settigns file similar to an INI.. however those are all easily spoofed and got round.

    placing your admin code in a different MDB means you can tie down the admin code using network permissions, the users don't know the code exists so there is no risk of them using it
    doing server stuff at scheduled intervals is smarter in my books.

    still its your application
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    I had something like this to prevent users running the front end from the master version (stored on a network share).

    All you need to do is have the code check the name of the resource (server, workstation) it is sat on right? If it is on <servername> then operate differently. Have I oversimplified or have you overcomplicated it?

  6. #6
    Join Date
    Mar 2010
    Posts
    88
    I guess the point I've not got across (because it wasn't relevant to my original direct question) is that this application has to be installable by non-experts, on systems whose name I don't know, and who I don't trust to make any complicated settings - this is why I'm trying to automate everything.

    As an example, I have bypassed the need to use the Linked Table Manager by using code and a nice easy browser window to look for b/e files.

    I do have a working solution of sorts: there is a password protected area where various stuff gets set up, and I had a simple tick box - is this the server? This works fine ... but its one more item for the installer to get wrong, which is why I was looking for a way to automate this. Looking to see if the backend files (whose names I know) are local or remote seemed like a good way of doing this...

  7. #7
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by CeejayDBF View Post
    on systems whose name I don't know
    That is key.

    Ok - I'm back to your original post. I think it would be safe enough to check for the first character of the BE tables being C, D or E and assume you are on the server if it is. BTW - I would actually hope the non-experts on not putting the file on the C drive of a server. The sort of server we are talking about is likely to only be a file server so not a high likelihood of more drives really.

    There would be more bullet proof ways of doing this if you need them.

  8. #8
    Join Date
    Mar 2010
    Posts
    88
    Quote Originally Posted by pootle flump View Post
    That is key.

    Ok - I'm back to your original post. I think it would be safe enough to check for the first character of the BE tables being C, D or E and assume you are on the server if it is. BTW - I would actually hope the non-experts on not putting the file on the C drive of a server. The sort of server we are talking about is likely to only be a file server so not a high likelihood of more drives really.

    There would be more bullet proof ways of doing this if you need them.
    Thanks. Well, I guess that's where I came in! You're probably right - C, D or E ought to cover it. In reality this is going to be a standard office PC being used as a server. So there are two problematic scenarios - one where the "server" has many drives and someone puts it on F. The other being where some awkward sod setting up a client decides to use E as a mapped drive.

    I am curious as to what the bullet proof ways might be, though?

    Thanks

  9. #9
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Off the top of my head, duplicate your API call code in the BE that checks the hostname of the machine. Automate the BE as part of the installation and write the result to a table. When your FE opens run the same code to find the FE's host and compare with the result in the BE table.

  10. #10
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Assumes of course no one will go in and change the value in the table so it is not resistant to malicious use.

  11. #11
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    If you're using UNC, You could extract the name of the computer from the connection string of a linked table (the Connect property of the TableDef object) and compare it to the name of the local machine (obtained using the GetComputerName API function). If both are the same, then the front-end is running on the server, if not it's running on a client.
    Have a nice day!

  12. #12
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    The problem is this is at any client's network and it might not be a UNC.
    Quote Originally Posted by Sinndho View Post
    If you're using UNC....
    Quote Originally Posted by CeejayDBF View Post
    I can't be sure which drive letter will have been used for mapping the share.

  13. #13
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're right pootle, but as he creates the link with his own code:
    I have bypassed the need to use the Linked Table Manager by using code
    he can ensure that UNC will always be used.
    Have a nice day!

  14. #14
    Join Date
    May 2010
    Posts
    601
    It is possible to find the local drive, removable drives and mapped drives. You can also determine the UNC path for mapped drive letter.

    This should help:

    Enumerating Local and Network Drives
    Boyd Trimmell aka HiTechCoach HiTechCoach.com (free access stuff)
    Microsoft MVP - Access Expert
    BPM/Accounting Systems/Inventory Control/CRM
    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

Posting Permissions

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