Adding users to work Group file with the help of code

A

Ashutosh

Hi Guys,

I have a ms access 97 database and there is a security
file (workgroup file) which makes the validation for each
users before letting them access the database.
Now i want to add users with different roles to this
security file using a vb code.
How can this be achieved.
Also if not vb code then what can be used

Thanks

ashutosh
 
G

Graham Mandeno

Hi Ashutosh

To add a new user:
Dim wks as Workspace
Dim usr as User
Set wks = DBEngine(0)
Set usr = wks.CreateUser(<username>, <PID>, <password>)
wks.Users.Append usr
usr.Groups.Append usr.CreateGroup("Users")

Note that this also adds the user to the required "Users" group. To add it
also to another group (assign a role), use:
usr.Groups.Append usr.CreateGroup("AccountsStaff")

--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand

Return mail address is invalid in a vain attempt to reduce spam.
Feedback is welcome at: (e-mail address removed)
Please post new questions or followups to newsgroup.
 
L

Leif

Note that in my experience you may add a user to a group,
and if you check via the User and Group Accounts... dialog
it will show them as added, but if they are currently
logged in they will not have the group permissions. They
must first log out and back in again.

Leif
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top