Topic
2 replies Latest Post - ‏2014-01-15T04:35:48Z by raj_kgdr
raj_kgdr
raj_kgdr
28 Posts
ACCEPTED ANSWER

Pinned topic extract user and group info

‏2014-01-10T09:01:51Z |

Hi All,

Just wonder if we have any utility in CQ which extracts only the user info and the group which he/she belongs to.

I just need to populate the list of users and the corresponding groups they belong to

or

A list of groups and list the users in the corresponding groups.

I tried the import uitility, but it gives me a big data, and I guess the group info is vomitted in this.

Thanks in advance for your help.

 

  • pdubovitsky
    pdubovitsky
    374 Posts
    ACCEPTED ANSWER

    Re: extract user and group info

    ‏2014-01-11T03:30:35Z  in response to raj_kgdr

    ClearQuest API would be the easiest way to do it. For example, this script would return a list of active users along with a comma separated list of groups they belong to.

    use CQPerlExt;
    
    if(scalar(@ARGV) < 3 ){
      print "Usage: $0 <username> <password> <dbset>\n";
      exit 1; 
    }
    
    my ($login, $password, $dbset) = @ARGV;
    
    
    my $as = CQAdminSession::Build();
    $as->Logon($login, $password, $dbset);
    
    # check all users
    my $users = $as->GetUsers();
    my $cnt = $users->Count();
    for(my $i = 0; $i < $cnt; $i++){
      my $user = $users->Item($i);
      my $name = $user->GetName();
      my $active = $user->GetActive();
      if( $active ){ 
        # report active users only
        my $groups = $user->GetGroups();
        my $grpcnt = $groups->Count();
        print "$name";
        for(my $j = 0; $j < $grpcnt; $j++){
          my $group = $groups->Item($j);
          my $group_name = $group->GetName();
          print ",$group_name";
        }
        print "\n";
      }
    }
    
    CQAdminSession::Unbuild($as);
    

    Pavel

    Updated on 2014-01-11T03:31:03Z at 2014-01-11T03:31:03Z by pdubovitsky