Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Security / October 2004

Tip: Looking for answers? Try searching our database.

Append New user to A Group

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jim Bunton - 03 Oct 2004 18:30 GMT
* I cannot append a new user to a group!
* Windows 2000 [Ia m Administrator]
* Access 97 I am logged in as a member of Admins
   I own every object
   I have full permission on every object
--------------------------------------------
I have now resorted to almost the identical code in the Access 97 help files
Users Object (DAO)
- code example 1 [with additions]
 'CreateUser Method and Password and PID Properties Example'
 [began without the additions]
-------------------------------------------

=== Code start =====
Private Sub Command2_Click()
On Error GoTo Err_Command2_Click
Dim WkSpace As Workspace, grpNew As Group, usrTemp As User
Dim usrMine As User

  Set WkSpace = DBEngine.Workspaces(0)

  With WkSpace
     ' Create and append new Group.
     Set grpNew = .CreateGroup("NewGroup", "AAA123456789")
     'THE NEXT succeeds
     .Groups.Append grpNew

     ' Make the user "NewUser" a member of the
     'group "NewGroup" by creating and adding the
     'appropriate User object to the group's Users
     'collection.
     Set usrTemp = .Groups("NewGroup").CreateUser("NewUser")
     Set usrMine = .CreateUser("MyNewUser", "123456", "Pwd")
     'usrTemp.PID = "AAA123456789"
     'usrTemp.Password = "NewPassword"
     'THE NEXT fails
     ' 3030 'NewUser' Isn't valid account
     .Groups("NewGroup").Users.Append usrTemp
     'THE NEXT succeeds
     .Users.Append usrMine
     'THE NEXT Fails
     '3219 - Invalid Operation
     .Groups("NewGroup").Users.Append usrMine

  End With

Exit_Command2_Click:
   Exit Sub

Err_Command2_Click:
   MsgBox Err & " - " & Err.Description
   Resume Next

End Sub
==== Code End ====

Signature

Jim Bunton
jBunton@Blueyonder.co.uk
13 Westbourne Road
Trowbridge
Wilts. BA14 0AJ
Tel: 01225 765 541
Mobile: 07919 283 968

Jim Bunton - 03 Oct 2004 19:31 GMT
BUT Note also that though
     'THE NEXT succeeds
     .Users.Append usrMine
usrMine, i.e."MyNewUser" does not belong to the 'Users' Group when inspected
with Tools>Security>acounts!

> * I cannot append a new user to a group!
> * Windows 2000 [Ia m Administrator]
[quoted text clipped - 51 lines]
> End Sub
> ==== Code End ====
Joan Wild - 04 Oct 2004 14:30 GMT
You need to refresh the Users collection after appending the user (and also
the groups after creating the group)
      .Groups.Append grpNew
       .Groups.Refresh
and
      .Users.Append usrMine
       .Users.Refresh

And you need to add the user to the Users group, and then add them to your
Group.

Signature

Joan Wild
Microsoft Access MVP

> BUT Note also that though
>       'THE NEXT succeeds
[quoted text clipped - 66 lines]
>> Tel: 01225 765 541
>> Mobile: 07919 283 968
Jim Bunton - 04 Oct 2004 16:23 GMT
Hm! - am I doing something obsurdly stupid?
This all works until
  .Groups("Users").Users.Append UsrNew
=======================
With WkSpace
     Set UsrNew = .CreateUser("aNewUser", "123456", "Pwd")
     .Users.Append UsrNew
     .Users.Refresh
     .Groups.Refresh
     .Groups("Users").Users.Refresh
     Set UsrNew = .Users("aNewUser")
     MsgBox UsrNew.Name & " - " & .Groups("Users").Name
     .Groups("Users").Users.Append UsrNew
     'AHHHH - Error
     'Err 3219 - Invalid operation
     'Mystified
End with
========================
> You need to refresh the Users collection after appending the user (and also
> the groups after creating the group)
[quoted text clipped - 77 lines]
> >> Tel: 01225 765 541
> >> Mobile: 07919 283 968
Joan Wild - 04 Oct 2004 19:00 GMT
Dim wrk As Workspace
Dim usrNew As User
Dim grp As Group

Set wrk = DBEngine.Workspaces(0)

'Create new group
   Set grp = wrk.CreateGroup("MyGroup", "12345")
   wrk.Groups.Append grp

'Create new user
   Set usrNew = wrk.CreateUser("SomeUser", "98766", "SomePassword")
   wrk.Users.Append usrNew

'Add user to Users and MyGroup groups
   wrk.Groups.Refresh
   wrk.Users.Refresh

   usrNew.Groups.Append wrk.CreateGroup("Users")
   usrNew.Groups.Append wrk.CreateGroup("MyGroup")

> Hm! - am I doing something obsurdly stupid?
> This all works until
[quoted text clipped - 13 lines]
>       'Mystified
> End with

Signature

Joan Wild
Microsoft Access MVP

Jim Bunton - 05 Oct 2004 12:52 GMT
Thanks for persisting Joan.

I now see the error of my ways -
confused by having to use syntax that inferred the creation of a Group that
already existed.
All now working fine - thanks again

> Dim wrk As Workspace
> Dim usrNew As User
[quoted text clipped - 34 lines]
> >       'Mystified
> > End with
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.