CreateUser Module

J

Justin

Hello,

I found this code on Microsoft.com. It is used to add a
new user to a database, assign that person to a workgroup,
assign a PID, and establish a password. It works, but I
need to be able to assign each user to 2 groups - Users
and (Staff17, Mngr18, StfAdmin19, or DbAdmin20).

If the new user is assigned to Mngr18 only, he/she cannot
open the database. If the new user is assigned to Users
only, he/she does not have access to any of the database
objects I created.

Can someone help me?

Thank you!

Function CUser(UName As String, upin As String, upwd As
String, gname As String)

Dim u As User, w As Workspace, g As Group
Set w = DBEngine.Workspaces(0)
Set u = w.CreateUser(UName, upin, upwd)

w.Users.Append u
w.Users.Refresh
Set g = w.Groups(gname)
Set u = g.CreateUser(UName)

g.Users.Append
g.Users.Refresh

End Function
 
S

Stan Miezeiwski

Change the function as follows:

Function CUser(UName As String, upin As String, upwd As
String, gname As String, gname2 as string)

Dim u As User, w As Workspace, g As Group
Set w = DBEngine.Workspaces(0)
Set u = w.CreateUser(UName, upin, upwd)

w.Users.Append u
w.Users.Refresh
Set g = w.Groups(gname)
Set u = g.CreateUser(UName)

g.Users.Append
g.Users.Refresh

set g = w.Groups(gname2)
set u = g.CreateUser(uname)

g.users.append
g.users.refresh

End Function

Type this quickly, but it should work.

Stan
 

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