PC Review


Reply
Thread Tools Rate Thread

Remove user from group

 
 
Scott Whetsell, A.S. - WVSP
Guest
Posts: n/a
 
      4th May 2008
I am trying to build a form that will allow those in supervisory positions to
be able to assign other users to different levels of access according to
group policy. I can get the Groups.Users.Append to work fine, but when I use
Groups.Users.Delete I get a 'Type Mismatch' error on the .Delete.

Here is a sniplet of the code I am using.

============START SNIPLET============
Dim CurrLvl As String ' Current Access Group
Dim NewLvl As String ' New Access Group
CurrLvl = Me.CurrAccLvl
NewLvl = Me.NewAccLvl
strUID = Me.txtCPWUserName
Set wrk = DBEngine.Workspaces(0)
With wrk
If CurrLvl = "View Only" Then
Set grpUsers = wrk.Groups("View Only")
Set usr = grpUsers.CreateUser(strUID)
grpUsers.Users.Delete usr
grpUsers.Users.Refresh
If (NewLvl = "Admins") Or (NewLvl = "Supervisors") Then
Set grpUsers = wrk.Groups("Admins")
Set usr = grpUsers.CreateUser(strUID)
grpUsers.Users.Append usr
grpUsers.Users.Refresh
If NewLvl = "Supervisors" Then
Set grpUsers = wrk.Groups("Supervisors")
Set usr = grpUsers.CreateUser(strUID)
grpUsers.Users.Append usr
grpUsers.Users.Refresh
End If
End If
============END SNIPLET============

My current user groups are Admins, Supervisors, Users, and View Only.
Admins and Users are the standard built in accounts.
Supervisors are also in the Admins group so they can add/change users, but
restricted from other Admin privledges.
View Only users are just that, they have read permissions only.




Thanks in advance.
 
Reply With Quote
 
 
 
 
Joan Wild
Guest
Posts: n/a
 
      4th May 2008
You don't need the .CreateUser() to delete them
Try simply

If CurrLvl = "View Only" Then
Set usr = wrk.Users(strUID)
usr.Groups.Delete "ViewOnly"
....

--
Joan Wild
Microsoft Access MVP
"Scott Whetsell, A.S. - WVSP" <(E-Mail Removed)> wrote in message news:3C074DEB-16EF-49F1-83CC-(E-Mail Removed)...
>I am trying to build a form that will allow those in supervisory positions to
> be able to assign other users to different levels of access according to
> group policy. I can get the Groups.Users.Append to work fine, but when I use
> Groups.Users.Delete I get a 'Type Mismatch' error on the .Delete.
>
> Here is a sniplet of the code I am using.
>
> ============START SNIPLET============
> Dim CurrLvl As String ' Current Access Group
> Dim NewLvl As String ' New Access Group
> CurrLvl = Me.CurrAccLvl
> NewLvl = Me.NewAccLvl
> strUID = Me.txtCPWUserName
> Set wrk = DBEngine.Workspaces(0)
> With wrk
> If CurrLvl = "View Only" Then
> Set grpUsers = wrk.Groups("View Only")
> Set usr = grpUsers.CreateUser(strUID)
> grpUsers.Users.Delete usr
> grpUsers.Users.Refresh
> If (NewLvl = "Admins") Or (NewLvl = "Supervisors") Then
> Set grpUsers = wrk.Groups("Admins")
> Set usr = grpUsers.CreateUser(strUID)
> grpUsers.Users.Append usr
> grpUsers.Users.Refresh
> If NewLvl = "Supervisors" Then
> Set grpUsers = wrk.Groups("Supervisors")
> Set usr = grpUsers.CreateUser(strUID)
> grpUsers.Users.Append usr
> grpUsers.Users.Refresh
> End If
> End If
> ============END SNIPLET============
>
> My current user groups are Admins, Supervisors, Users, and View Only.
> Admins and Users are the standard built in accounts.
> Supervisors are also in the Admins group so they can add/change users, but
> restricted from other Admin privledges.
> View Only users are just that, they have read permissions only.
>
>
>
>
> Thanks in advance.

 
Reply With Quote
 
Scott Whetsell, A.S. - WVSP
Guest
Posts: n/a
 
      4th May 2008
Joan,

Thanks for pointing me in the painfully obvious direction again!

Take care.


"Joan Wild" wrote:

> You don't need the .CreateUser() to delete them
> Try simply
>
> If CurrLvl = "View Only" Then
> Set usr = wrk.Users(strUID)
> usr.Groups.Delete "ViewOnly"
> ....
>
> --
> Joan Wild
> Microsoft Access MVP
> "Scott Whetsell, A.S. - WVSP" <(E-Mail Removed)> wrote in message news:3C074DEB-16EF-49F1-83CC-(E-Mail Removed)...
> >I am trying to build a form that will allow those in supervisory positions to
> > be able to assign other users to different levels of access according to
> > group policy. I can get the Groups.Users.Append to work fine, but when I use
> > Groups.Users.Delete I get a 'Type Mismatch' error on the .Delete.
> >
> > Here is a sniplet of the code I am using.
> >
> > ============START SNIPLET============
> > Dim CurrLvl As String ' Current Access Group
> > Dim NewLvl As String ' New Access Group
> > CurrLvl = Me.CurrAccLvl
> > NewLvl = Me.NewAccLvl
> > strUID = Me.txtCPWUserName
> > Set wrk = DBEngine.Workspaces(0)
> > With wrk
> > If CurrLvl = "View Only" Then
> > Set grpUsers = wrk.Groups("View Only")
> > Set usr = grpUsers.CreateUser(strUID)
> > grpUsers.Users.Delete usr
> > grpUsers.Users.Refresh
> > If (NewLvl = "Admins") Or (NewLvl = "Supervisors") Then
> > Set grpUsers = wrk.Groups("Admins")
> > Set usr = grpUsers.CreateUser(strUID)
> > grpUsers.Users.Append usr
> > grpUsers.Users.Refresh
> > If NewLvl = "Supervisors" Then
> > Set grpUsers = wrk.Groups("Supervisors")
> > Set usr = grpUsers.CreateUser(strUID)
> > grpUsers.Users.Append usr
> > grpUsers.Users.Refresh
> > End If
> > End If
> > ============END SNIPLET============
> >
> > My current user groups are Admins, Supervisors, Users, and View Only.
> > Admins and Users are the standard built in accounts.
> > Supervisors are also in the Admins group so they can add/change users, but
> > restricted from other Admin privledges.
> > View Only users are just that, they have read permissions only.
> >
> >
> >
> >
> > Thanks in advance.

>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove user from local group John Microsoft C# .NET 2 18th Jun 2008 01:43 PM
Re: Remove SID/User from a local Group Policy Ken B Microsoft Windows 2000 Security 2 14th Mar 2005 08:43 PM
Re: Remove SID/User from a local Group Policy Justin Microsoft Windows 2000 Security 3 11th Mar 2005 12:43 AM
How to add/remove a user from a group in logon script Graham Prentice Microsoft Windows 2000 Group Policy 3 19th Aug 2004 08:15 AM
Remove A User From A Group Ram Microsoft C# .NET 3 9th Jul 2004 09:37 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:35 AM.