Bob Hughes wrote:
(snip)
My next question is about the PID. For each new user I could:
Use the same PID.
Create a random PID.
Use a table of PID's & increment it.
What do you recommend?
Whatever you do, don't choose any method that lets an evil person guess
its value! (so methods 1 & 3 above are out) Otherwise, it is possible
to impersonate that user by recreating him in a different workgroup
file.
Here's how it works.
To the underlying MS Jet database engine, users are not really defined
by usernames. They are defined by username *plus PID*. The combination
of username + PID is assigned a unique binary number called a Security
Identifier (SID). It is the SID which really defines that user, not his
username.
When permissions are stored within a database (mdb) file, they are
stored against SIDs - *not* usernames. For example:
workgroup file:
username: Fred
PID: 1234
SID: 10F369A7B4402D
database:
table: MySecretData
SID: 10F369A7B4402D
perms: Read only
I imagine there are two reasons why the Jet team did it like that.
(1) You can't acquire a person's permissions just by creating a new
workgroup file then adding a new user with the relevant name. You'd
have to know their PID, as well.
(2) You might have a person Fred Smith in workgroup file #1, and a
different person also called Fred Smith in workgroup file #2. If
permissions were based on usernames, there would be no way to
distinguish the permissions for those two people. But with the method
described above, if you give them different PIDs, they will get
different SIDs, so they will be (in effect) completely different users
to Jet & Access.
This shows the amazing level of thought that the Jet team gave, to the
whole security mechanism. It is truly a work of wonder, in every
respect except one! They made some absolute cryptograhpic "schoolboy
howlers" pertaining to the workgroup file. Hence the existance of
programs that can reverse-engineer the usernames, PIDs and passwords
from a workgroup file. With the tiniest of tiny Jet code changes, it
would not be possible to reverse engineer that information from a
workgroup file. I have put this to MS, but they are not interested :-(
And I don't have the level of win32 skills necessary to write a program
that would patch Jet in memory, at runtime.
So, go the random PIDs! Don't make PIDs predictable. It doesn't matter
if two different people get the same PID (by chance). They will still
have different SIDs (because their usernames are different), so they
will still look different to Jet.
HTH,
TC