Having problems adding a user in a role 
Author Message
 Having problems adding a user in a role

See:

NTadminCode VB
http://www.*-*-*.com/

Scroll 'till you see the section on:
User and Group Management

Quote:

> I'm having problems with a code that i've picked up of microsoft's web
> site.
> I need to set up a user in a role. The folowing example doesn't
> wor'k and I don't know exactly why.
> If someone know how to set up a user in a role and want to help-me
> please write to me.

> Begin of the code
> ****************************
> Private Sub Command1_Click()

> Dim catalog As Object
> Dim packages As Object
> Dim pack As Object
> Dim comp As Object
> Dim role As Object
> Dim newUser As Object
> Dim newRole As Object
> Dim componentsInPack As Object
> Dim RolesInPackage As Object
> Dim usersInRole As Object
> Dim rolesForComponent As Object
> Dim util As Object

> 'On Error GoTo failed

> Set catalog = CreateObject("MTSAdmin.Catalog.1")
> Set packages = catalog.GetCollection("Packages")
> packages.Populate

> For Each pack In packages    'This part was missing in the example

>     If pack.Name = "My Package" Then
>         Set rolesInPack = packages.GetCollection("RolesInPackage",
> pack.Key)
>         For Each newRole In RolesInPackage
>                 Set newRole = RolesInPackage.Add
>                 newRole.Value("Name") = "R1"
>                 rolesInPack.savechanges

>                 Set usersInRole =
> RolesInPackage.GetCollection("UsersInRole", newRole.Key)
>                 Set newUser = usersInRole.Add
>                 newUser.Value("User") = "administrator"
>                 usersInRole.savechanges

>         Set componentsInPack =
> packages.GetCollection("ComponentsInPackage", pack.Key)
>         componentsInPack.Populate
>         For Each comp In componentsInPack
>             If comp.Name = "Bank.Account" Then
>                 Set rolesForComponent =
> componentsInPack.GetCollection("RolesForPackageComponent", comp.Key)
>                 Set util = rolesForComponent.GetUtilInterface
>                 util.associateRole (newRole.Key)
>                 Exit For
>             End If
>         Next
>         Exit For 'Falta o correspondente deste commando
>     Next
>     End If
> Next

>     Exit Sub

> End Sub



Wed, 19 Feb 2003 00:57:36 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Having problems with a hyperlink I added to a form

2. Having problem adding record...

3. Having problem with Adding a New Printer Port???

4. New user having problems and would appreciate any help

5. HELP - Having problem with Database.Execute in mulit-user envirinment

6. user having problem with versions

7. Role-Based Security Using User's Windows Account Info Not Working Under Win9x

8. Enumerating a users roles.

9. Users, Groups & Roles

10. Get list of users belonging to COM+ role?

11. Getting SQL Sever User Role Information

12. How can I get Role for Current User from SQL Server using VB6 ADO connection

 

 
Powered by phpBB® Forum Software