<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Check group membership of Alfresco user in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/check-group-membership-of-alfresco-user/m-p/93547#M27656</link>
    <description>&lt;P&gt;How to check if any alfresco user &lt;EM&gt;'abc'&lt;/EM&gt; is a member of Alfresco group &lt;EM&gt;'DEF'&amp;nbsp;&amp;nbsp;&lt;/EM&gt;by using Alfresco java APIs?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 08 Aug 2020 11:31:19 GMT</pubDate>
    <dc:creator>alf_developer09</dc:creator>
    <dc:date>2020-08-08T11:31:19Z</dc:date>
    <item>
      <title>Check group membership of Alfresco user</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/check-group-membership-of-alfresco-user/m-p/93547#M27656</link>
      <description>&lt;P&gt;How to check if any alfresco user &lt;EM&gt;'abc'&lt;/EM&gt; is a member of Alfresco group &lt;EM&gt;'DEF'&amp;nbsp;&amp;nbsp;&lt;/EM&gt;by using Alfresco java APIs?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Aug 2020 11:31:19 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/check-group-membership-of-alfresco-user/m-p/93547#M27656</guid>
      <dc:creator>alf_developer09</dc:creator>
      <dc:date>2020-08-08T11:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: Check group membership of Alfresco user</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/check-group-membership-of-alfresco-user/m-p/93548#M27657</link>
      <description>&lt;P&gt;If i understand correctly, you want to know groups of a user. You can use combination of &lt;A href="https://docs.alfresco.com/5.2/references/dev-services-node.html" target="_self" rel="nofollow noopener noreferrer"&gt;&amp;nbsp;&amp;nbsp;&lt;/A&gt;&lt;A href="https://docs.alfresco.com/5.2/references/dev-services-person.html" target="_self" rel="nofollow noopener noreferrer"&gt;PersonService&lt;/A&gt; and &lt;A href="https://docs.alfresco.com/5.2/references/dev-services-authority.html" target="_self" rel="nofollow noopener noreferrer"&gt;AuthorityService&amp;nbsp;&lt;/A&gt;depending on requirements.&lt;/P&gt;
&lt;P&gt;&lt;U&gt;To get authorities of a user, considering userName is already known:&amp;nbsp;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://dev.alfresco.com/resource/docs/java/org/alfresco/service/cmr/security/AuthorityService.html#getAuthoritiesForUser-java.lang.String-" target="_blank" rel="noopener nofollow noreferrer"&gt;https://dev.alfresco.com/resource/docs/java/org/alfresco/service/cmr/security/AuthorityService.html#getAuthoritiesForUser-java.lang.String-&lt;/A&gt;&lt;/P&gt;
&lt;PRE&gt;final Set&amp;lt;String&amp;gt; authorities = authorityService.getAuthoritiesForUser("&lt;EM&gt;&lt;STRONG&gt;abc&lt;/STRONG&gt;&lt;/EM&gt;"); // abc is a username
final boolean hasDEF = authorities.contains("&lt;EM&gt;&lt;STRONG&gt;GROUP_DEF&lt;/STRONG&gt;&lt;/EM&gt;"); //DEF is a group. Make sure to prepend "GROUP_" qualifier for any group&lt;/PRE&gt;

&lt;P&gt;Additionally,&amp;nbsp;You can also use OOTB '&lt;A href="https://docs.alfresco.com/5.0/references/RESTful-PersonPersonGet.html" target="_self" rel="nofollow noopener noreferrer"&gt;People&lt;/A&gt;' (Get Person) rest api.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example if you want to know the details of a user e.g. 'admin', then:&lt;/P&gt;
&lt;PRE&gt;GET: &amp;lt;host&amp;gt;:&amp;lt;post&amp;gt;/alfresco/service/&lt;STRONG&gt;api/people/admin?groups=true&lt;/STRONG&gt;

e.g.

http://127.0.0.1:7080/alfresco/service/&lt;STRONG&gt;api/people/admin?groups=true&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;U&gt;This will return info about 'admin' user and all its groups. See the sample response below:&lt;/U&gt;&lt;/P&gt;
&lt;PRE&gt;{
url: "/alfresco/service/api/people/admin",
&lt;STRONG&gt;userName: "admin",
&lt;/STRONG&gt;enabled: true,
firstName: "Administrator",
lastName: "",
jobtitle: null,
organization: null,
organizationId: "",
location: null,
telephone: null,
mobile: null,
email: "admin@alfresco.com",
companyaddress1: null,
companyaddress2: null,
companyaddress3: null,
companypostcode: null,
companytelephone: null,
companyfax: null,
companyemail: null,
skype: null,
instantmsg: null,
userStatus: null,
userStatusTime: null,
googleusername: null,
quota: -1,
sizeCurrent: 0,
emailFeedDisabled: false,
persondescription: null,
authorizationStatus: null,
isDeleted: false,
isAdminAuthority: true,
capabilities: {
isAdmin: true,
isMutable: true,
isGuest: false
},
&lt;STRONG&gt;groups: [
{
itemName: "GROUP_ALFRESCO_ADMINISTRATORS",
displayName: "ALFRESCO_ADMINISTRATORS"
},
{
itemName: "GROUP_ALFRESCO_MODEL_ADMINISTRATORS",
displayName: "ALFRESCO_MODEL_ADMINISTRATORS"
},
{
itemName: "GROUP_ALFRESCO_SEARCH_ADMINISTRATORS",
displayName: "ALFRESCO_SEARCH_ADMINISTRATORS"
},
{
itemName: "GROUP_EMAIL_CONTRIBUTORS",
displayName: "EMAIL_CONTRIBUTORS"
},
{
itemName: "GROUP_SITE_ADMINISTRATORS",
displayName: "SITE_ADMINISTRATORS"
}
],&lt;/STRONG&gt;
immutability: { }
}&lt;/PRE&gt;
&lt;P&gt;Once you get the response, you can parse the json and apply any additonal filtering logic on it as per your use case.&lt;/P&gt;</description>
      <pubDate>Sat, 08 Aug 2020 16:24:26 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/check-group-membership-of-alfresco-user/m-p/93548#M27657</guid>
      <dc:creator>abhinavmishra14</dc:creator>
      <dc:date>2020-08-08T16:24:26Z</dc:date>
    </item>
    <item>
      <title>Re: Check group membership of Alfresco user</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/check-group-membership-of-alfresco-user/m-p/93549#M27658</link>
      <description>&lt;P&gt;Thanks, it worked !&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2020 14:35:51 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/check-group-membership-of-alfresco-user/m-p/93549#M27658</guid>
      <dc:creator>alf_developer09</dc:creator>
      <dc:date>2020-09-01T14:35:51Z</dc:date>
    </item>
    <item>
      <title>Re: Check group membership of Alfresco user</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/check-group-membership-of-alfresco-user/m-p/93550#M27659</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://migration33.stage.lithium.com/t5/user/viewprofilepage/user-id/26558"&gt;@alf_developer09&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for updating &amp;amp; accepting the solution - really helpful to other users.&lt;/P&gt;
&lt;P&gt;Thanks again,&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2020 15:39:03 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/check-group-membership-of-alfresco-user/m-p/93550#M27659</guid>
      <dc:creator>EddieMay</dc:creator>
      <dc:date>2020-09-01T15:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: Check group membership of Alfresco user</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/check-group-membership-of-alfresco-user/m-p/93551#M27660</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Is it possible to call the authoritiesService from Share?&lt;/P&gt;&lt;P&gt;I need to do something similar for an evaluator.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Francisco Duarte&lt;/P&gt;</description>
      <pubDate>Mon, 14 Nov 2022 14:59:29 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/check-group-membership-of-alfresco-user/m-p/93551#M27660</guid>
      <dc:creator>franciscoduarte</dc:creator>
      <dc:date>2022-11-14T14:59:29Z</dc:date>
    </item>
  </channel>
</rss>

