User acct and group management forms/code?

  • Thread starter Thread starter kiln
  • Start date Start date
K

kiln

Does anyone know of an Access book or website that has decent group and
user managment example forms and code? I would like to offer user
creation etc, group memberships, password management and so forth to end
users via regular Access forms, not the built in dialogs that Access
comes with. I'm not finding any such forms etc that come with the
various Access books I have...but such would be a great head start.
Anyone know of a book or website that offers this sort of thing?

Thanks
 
The built-in security UI is terrible IMHO. But a new version of Access
(Access 12) is now out for beta testing. It remains to be seen, what
they have done to/with security & whether it still exists in its
previous form.

HTH,
TC
 
The built-in security UI is terrible IMHO. But a new version of Access
(Access 12) is now out for beta testing. It remains to be seen, what
they have done to/with security & whether it still exists in its
previous form.

HTH,
TC
Hi - I'd bet that the general security model remains more or less
intact. It's not changed since the very early days, and as far as I can
tell, the changes going into the new version of Access have more to do
with interface changes and less to do with fundementals. In any case,
the current need is for a solution that works with Access 2003.
 
These code samples were posted by MVP Graham Seach in this group
quite a while ago. These should help you build some forms. I will at
some point post some ready made forms for this type of thing, but it
is a bit down on my to-do list at the moment.

Here you go:
'Enumerate all users and groups
Public Sub EnumUsersAndGroups()
Dim wrk As DAO.Workspace
Dim grp As DAO.Group
Dim usr As DAO.User

Set wrk = DBEngine(0)

'Enumerate the groups
Debug.Print "Groups."
For Each grp In wrk.Groups
Debug.Print vbTab & grp.Name
Next grp

'Enumerate the users
Debug.Print "Users."
For Each usr In wrk.Users
Debug.Print vbTab & usr.Name
Next usr

Set grp = Nothing
Set wrk = Nothing
End Sub

'-------
'Enumerate the users belonging to a specific group
Public Sub EnumGroupUsers(strGroup As String)
Dim wrk As DAO.Workspace
Dim varUser As Variant

Set wrk = DBEngine(0)

Debug.Print "Users belonging to the '" & strGroup & "' group..."
For Each varUser In wrk.Groups(strGroup).Users
Debug.Print vbTab & varUser.Name
Next varUser

Set wrk = Nothing
End Sub

'-------
'Enumerate the groups a specific user belongs to
Public Sub EnumUserGroups(strUser As String)
Dim wrk As DAO.Workspace
Dim varGroup As Variant

Set wrk = DBEngine(0)

Debug.Print "Groups to which user '" & strUser & "' belongs..."
For Each varGroup In wrk.Users(strUser).Groups
Debug.Print vbTab & varGroup.Name
Next varGroup

Set wrk = Nothing
End Sub

'-------
'Create a group
Public Sub CreateUserGroup(strGroupName As String, _
strPID As String)
Dim wrk As DAO.Workspace
Dim grp As DAO.Group

Set wrk = DBEngine(0)
On Error GoTo CreateUserGroupErr

'Create the new group
Set grp = wrk.CreateGroup(strGroupName, strPID)
ws.Groups.Append grp

CreateUserGroupErr:
Set grp = Nothing
Set wrk = Nothing
End Sub

'-------
'Delete a group
Public Sub DeleteGroup(strGroup As String)
On Error Resume Next
DBEngine(0).Groups.Delete strGroup
End Sub

'-------
'Create a user
Public Function CreateUserAccount(strUserName As String, _
strPID As String, strPassword As String)
Dim wrk As DAO.Workspace
Dim usr As DAO.User

Set wrk = DBEngine(0)
On Error GoTo CreateUserAccountErr

'Create the new user
Set usr = wrk.CreateUser(strUserName, strPID, strPassword)
wrk.Users.Append usr

CreateUserAccountErr:
Set usr = Nothing
Set wrk = Nothing
End Function

'-------
'Delete a user
Public Sub DeleteUser(strUser As String)
On Error Resume Next
DBEngine(0).Users.Delete strUser
End Sub

'-------
'Add a group to a user
Public Sub AddGroup2User(strUser As String, _
strGroup As String)
Dim wrk As DAO.Workspace
Dim usr As DAO.User
Dim grp As DAO.Group

Set wrk = DBEngine(0)
On Error Resume Next

'Create object references
Set usr = wrk.Users(strUser)
Set grp = usr.CreateGroup(strGroup)

'Add the group to the user's Groups collection
usr.Groups.Append grp
usr.Groups.Refresh

Set usr = Nothing
Set grp = Nothing
Set wrk = Nothing
End Sub

'-------
'Add a user to a group
Public Sub AddUser2Group(strUser As String, _
strGroup As String)
Dim wrk As DAO.Workspace
Dim usr As DAO.User
Dim grp As DAO.Group

Set wrk = DBEngine(0)
On Error Resume Next

'Create object references
Set grp = wrk.Groups(strUser)
Set usr = grp.CreateUser(strUser)

'Add the group to the user's Groups collection
grp.Users.Append usr
grp.Users.Refresh

Set usr = Nothing
Set grp = Nothing
Set wrk = Nothing
End Sub

'-------
'Remove a user from a group
Public Sub DeleteUserFromGroup(strUser As String, _
strGroup As String)
Dim wrk As DAO.Workspace

Set wrk = DBEngine(0)
On Error Resume Next

wrk.Users(strUser).Groups.Delete strGroup

Set wrk = Nothing
End Sub

'-------
'Determine if a user belongs to a specific group
Public Function IsUserInGroup (strUser As String, _
strGroup As String) As Boolean
Dim wrk As DAO.Workspace

Set wrk = DBEngine(0)
On Error Resume Next

IsUserInGroup = False

'Check in the Users --> Groups collection
IsUserInGroup = _
(wrk.Users(strUser).Groups(strGroup).Name = strGroup)

'You can also do it this way...
'Check in the Groups --> Users collection
'IsUserInGroup = _
(wrk.Groups(strGroup).Users(strUser).Name = strUser)

Set wrk = Nothing
End Function

'-------
'Change a user's password
Public Sub ChangePassword(strUser As String, _
strOldPassword As String, strNewPassword As String)
Dim wrk As DAO.Workspace
Dim usr As DAO.User

Set wrk = DBEngine(0)
Set usr = wrk.Users(strUser)

'Change the password
usr.NewPassword strOldPassword, strNewPassword

Set usr = Nothing
Set wrk = Nothing
End Sub

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia[/QUOTE][/QUOTE][/QUOTE]
--
Jeff Conrad
Access Junkie - MVP
http://home.bendbroadband.com/conradsystems/accessjunkie.html
http://www.access.qbuilt.com/html/articles.html


in message:
 
kiln said:
Hi - I'd bet that the general security model remains more or less intact.

I wouldn't bet on that! See their comments at blogs.msdn.com/access.
They seem to imply that it will only continue (in its current form)
when using the old file formats, but not when using the new ones.

I'll be downloading the technical beta in about 2 hours & will check
this out.

Cheers,
TC
 
I wouldn't bet on that! See their comments at blogs.msdn.com/access.
They seem to imply that it will only continue (in its current form)
when using the old file formats, but not when using the new ones.

I'll be downloading the technical beta in about 2 hours & will check
this out.

Cheers,
TC
OK, interesting, thanks.
 
Hmm, this is the first technical beta that I have been on, and I did
not realize that "comments are verboten" until the end of the process.
I believe that this will be April next year. So there will be little if
any public comment before then, but then a swarm of comments from all
concerned!

It is no secret however that there have definitely? possibly? probably?
been some significant changes to Jet security. Erik Rucker said this on
his blog, but unfortunately, it was not very clear, IMHO. So we will
have to poke & prod it over the next few months, to find out for
ourselves.

He did say that traditional user-level security will be kept when using
the "old file formats", ie. mdb files. The question is, what happens
when you choose the "new" file formats.

Cheers,
TC
 
Back
Top