By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,046 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

A97: If I create a new user with CreateUser Method, is she automatically a member of Users group?

P: n/a
MLH
A97: If I create a new user with CreateUser Method, is she
automatically a member of Users group? Or, do I have to
append her to that group?
Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"MLH" <CR**@NorthState.net> wrote in message
news:b6********************************@4ax.com...
A97: If I create a new user with CreateUser Method, is she
automatically a member of Users group? Or, do I have to
append her to that group?


After you create and append the new user to the users collection you can do
MsgBox usr.Groups.Count
Which will tell you that the new user is not a member of any groups. This
contrasts to when you create a new user with the workgroup administrator -
here they are automatically appende to the Users group. In DAO you have to
explicitly do this - and the syntax might not be obvious - look at how you
need two lots of CreateUser:

Private Sub AddUser()

On Error GoTo Err_Handler

Dim wks As DAO.Workspace
Dim usr As DAO.User
Dim grp As DAO.Group

Set wks = DBEngine.Workspaces(0)

Set usr = wks.CreateUser("MyUser", "MyPID", "MyPassword")

wks.Users.Append usr

wks.Users.Refresh

Set grp = wks.Groups("Users")

Set usr = grp.CreateUser("MyUser")

grp.Users.Append usr

grp.Users.Refresh

Exit_Handler:

On Error Resume Next

Set usr = Nothing

Set grp = Nothing

Set wks = Nothing

Exit Sub

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Sub
Nov 13 '05 #2

P: n/a
MLH
<snip>
Yes, I noticed CreateUser being used twice. Was difficult to grasp.
Thx for reply.

After you create and append the new user to the users collection you can do
MsgBox usr.Groups.Count
Which will tell you that the new user is not a member of any groups. This
contrasts to when you create a new user with the workgroup administrator -
here they are automatically appende to the Users group. In DAO you have to
explicitly do this - and the syntax might not be obvious - look at how you
need two lots of CreateUser:

Private Sub AddUser()

On Error GoTo Err_Handler

Dim wks As DAO.Workspace
Dim usr As DAO.User
Dim grp As DAO.Group

Set wks = DBEngine.Workspaces(0)

Set usr = wks.CreateUser("MyUser", "MyPID", "MyPassword")

wks.Users.Append usr

wks.Users.Refresh

Set grp = wks.Groups("Users")

Set usr = grp.CreateUser("MyUser")

grp.Users.Append usr

grp.Users.Refresh

Exit_Handler:

On Error Resume Next

Set usr = Nothing

Set grp = Nothing

Set wks = Nothing

Exit Sub

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Sub


Nov 13 '05 #3

P: n/a
On Mon, 06 Jun 2005 17:50:04 -0400, MLH <CR**@NorthState.net> wrote:
A97: If I create a new user with CreateUser Method, is she
automatically a member of Users group? Or, do I have to
append her to that group?

Hi
Try it and see?
David

Nov 13 '05 #4

P: n/a
MLH
You're right. Best way is to
try it and see. I did. New users
are automatically appended to
the Users group - but not to any
other groups.

Thx.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi
Try it and see?
David


Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.