cancel
Showing results for 
Search instead for 
Did you mean: 

What groups is a user part of

jenglert
Champ in-the-making
Champ in-the-making
Does anyone know an easy/quick method to tell which groups a user is part of?
5 REPLIES 5

stk137
Champ in-the-making
Champ in-the-making
I don't know of one in the UI.
I definitely like a way to manage groups a user is a member of rather than having to go to each group one at a time and add the user.

There is this
http://wiki.alfresco.com/wiki/JavaScript_API#People_API

Array getContainerGroups(ScriptNode person)
  Gets the groups that contain the specified authority.

which could be used in a template to create a custom view or something.

rosemaryl
Champ in-the-making
Champ in-the-making
This is kind of dumb, I'm sure I'm just not looking in the right places, but once I do a call to getContainerGroups(…) I get a list of objects of type authorityContainer ({http://www.alfresco.org/model/user/1.0}authorityContainer).  I've been looking for some documentation for this type, namely, its properties so that I can get a human-readable group name out of it.

Thanks in advance!
~Rosemary

andy
Champ on-the-rise
Champ on-the-rise
Hi

This is in userModel.xml


<model name="usr:usermodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <description>Alfresco User Model</description>
   <author>Alfresco</author>
   <published>2005-08-16</published>
   <version>0.1</version>

   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <import uri="http://www.alfresco.org/model/system/1.0" prefix="sys"/>
   </imports>
  
   <namespaces>
      <namespace uri="http://www.alfresco.org/model/user/1.0" prefix="usr"/>
   </namespaces>

   <constraints>
     <constraint name="usr:userNameConstraint" type="org.alfresco.repo.dictionary.constraint.UserNameConstraint" />
      <constraint name="usr:authorityNameConstraint" type="org.alfresco.repo.dictionary.constraint.AuthorityNameConstraint" />
   </constraints>
  
   <types>
     
      <type name="usr:authority">
        <title>Alfresco Authority Abstract Type</title>
         <parent>sys:base</parent>
      </type>
     
      <type name="usr:user">
         <title>Alfresco User Type</title>
         <parent>usr:authority</parent>
         <properties>
         <!– The tokenisation set here is ignored - it is fixed for this type –>
         <!– This is so you can not break person lookup –>
            <property name="usr:username">
               <type>d:text</type>
            <constraints>
                  <constraint ref="usr:userNameConstraint" />
               </constraints>
            </property>
            <property name="usr:password">
               <type>d:text</type>
            </property>
            <property name="usr:enabled">
               <type>d:boolean</type>
            </property>
            <property name="usr:accountExpires">
               <type>d:boolean</type>
            </property>
            <property name="usr:accountExpiryDate">
               <type>d:datetime</type>
            </property>
            <property name="usr:credentialsExpire">
               <type>d:boolean</type>
            </property>
            <property name="usr:credentialsExpiryDate">
               <type>d:datetime</type>
            </property>
            <property name="usr:accountLocked">
               <type>d:boolean</type>
            </property>
            <property name="usr:salt">
               <type>d:text</type>
            </property>
         </properties>
      </type>
  
      <type name="usr:authorityContainer">
         <title>Alfresco Authority Type</title>
         <parent>usr:authority</parent>
         <properties>
         <!– The tokenisation set here is ignored - it is fixed for this type –>
         <!– This is so you can not break group lookup –>
            <property name="usr:authorityName">
               <type>d:text</type>
            <constraints>
                  <constraint ref="usr:authorityNameConstraint" />
               </constraints>
            </property>
            <property name="usr:members">
               <type>d:text</type>
               <multiple>true</multiple>  
            </property>
         </properties>
         <associations>
            <child-association name="usr:member">
               <source>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </source>
               <target>
                  <class>usr:authority</class>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </target>
               <duplicate>false</duplicate>
            </child-association>
         </associations>
      </type> 

   </types>
  
  
</model>

Andy

rosemaryl
Champ in-the-making
Champ in-the-making
Thanks Andy. 
Using the method of trial-and-error, I managed to get the information I wanted using a webscript.

Here are the guts of it, if anyone wants it (of course there's an xml file to go with this, but it's pretty standard, takes the username as a parameter):
usergroups.get.js

/*
Get User Groups Webscript Javascript file
*/
var person = people.getPerson(args["name"]);
model.groups = people.getContainerGroups(person);
model.test = new Array();
var containerGroups = people.getContainerGroups(person);
for(var i=0;i<containerGroups.length;i++){
   model.test = containerGroups[i].getQnamePath();
}

model.personName = person;

usergroups.get.html.ftl

<img src="/alfresco/images/logo/AlfrescoLogo32.png" alt="Alfresco" style="padding-right: 10px;"/><span class="mainTitle">User Groups</span>
<div style="margin-top: 10px;">
   User ${personName.properties.userName} (${personName.properties.firstName} ${personName.properties.lastName}) is part of the groups:
   <ul>
   <#list groups as group>
      <li>
         ${group.qnamePath}
   </#list>
   </ul>
</div>

aniruddh
Champ in-the-making
Champ in-the-making
I don't know of one in the UI.
I definitely like a way to manage groups a user is a member of rather than having to go to each group one at a time and add the user.

There is this
http://wiki.alfresco.com/wiki/JavaScript_API#People_API

Array getContainerGroups(ScriptNode person)
  Gets the groups that contain the specified authority.

which could be used in a template to create a custom view or something.

Is this possible using WebServices?