Create groups

To add users to groups, you need to call principal-update as your application’s Administrator user.

Add a user to a group

  1. Log in as your application’s Administrator user.

  2. (Optional) If the user does not yet exist, create the user with <<UNRESOLVED XREF>> principal-update:

    https://example.com/api/xml?action=principal-update 
        &first-name=jazzwayjazz&last-name=doe&login=jazz@doe.com 
        &password=nothing&type=user&has-children=0
  3. (Optional) Parse the response for the new user’s principal-id .

  4. If the user already exists, call principal-list to get the user’s principal-id :

    https://example.com/api/xml?action=principal-list&filter-type=user
  5. Parse the response for the principal-id :

    <principal principal-id="5611980" account-id="624520" type="user"  
            has-children="false" is-primary="false" is-hidden="false"> 
        <name>Joy Black</name>  
        <login>joy@acme.com</login>  
        <email>joy@acme.com</email>  
    </principal>
  6. Call principal-list again to get the group’s principal-id :

    https://example.com/api/xml?action=principal-list&filter-type=group
  7. Call group-membership-update with is-member=true to add the user to the group:

    https://example.com/api/xml?action=group-membership-update 
        &group-id=4930296&principal-id=2006258745&is-member=true
    • The principal-id is the user’s principal-id .

    • The group-id is the group’s principal-id .

    • The parameter is-member must be true .

Check whether a specific user is in a group

  1. Call principal-list with a group-id , filter-is-member , and a filter that identifies the principal:

    https://example.com/api/xml?action=principal-list&group-id=624523 
            &filter-is-member=true&filter-like-name=bob
  2. Parse for a principal element in the response. A successful response looks like this:

    <principal-list> 
        <principal principal-id="624660" account-id="624520" type="user"  
                has-children="false" is-primary="false" is-hidden="false"> 
            <name>Bill Jones</name>  
            <login>bjones@acme.com</login>  
            <email>bjones@acme.com</email>  
            <is-member>true</is-member>  
        </principal> 
    </principal-list>

    If the user is not a group member, the principal-list element is empty:

    <?xml version="1.0" encoding="utf-8" ?>  
    <results> 
        <status code="ok" />  
        <principal-list />  
    </results>

Check which users are in a group

  1. To get the group’s principal-id , call principal-list with filters:

    https://example.com/api/xml?action=principal-list&filter-type=group 
            &filter-name=developers

    With filter-type and filter-name , principal-list should return a unique match.

  2. Parse the response for the principal-id :

    <principal principal-id="2007105030" account-id="624520"  
            type="group" has-children="true" is-primary="false"  
            is-hidden="false"> 
        <name>developers</name>  
        <login>developers</login>  
        <is-member>false</is-member>  
    </principal>
  3. Call principal-list again, with the principal-id as a group-id and filter-is-member=true :

    https://example.com/api/xml?action=principal-list&group-id=2007105030 
            &filter-is-member=true
  4. Parse the response for the principal elements:

    <principal principal-id="5698354" account-id="624520" type="group"  
                has-children="true" is-primary="false" is-hidden="false"> 
        <name>Bob Jones</name>  
        <login>bobjones@acme.com</login>  
        <is-member>true</is-member>  
    </principal>

List all groups a user belongs to

  1. Call principal-list with the user’s principal-id and filter-is-member=true :

    https://example.com/api/xml?action=principal-list 
        &principal-id=2006258745&filter-is-member=true
  2. Parse the response for the principal elements:

    <principal principal-id="5698354" account-id="624520" type="group"  
                has-children="true" is-primary="false" is-hidden="false"> 
        <name>Bob Jones</name>  
        <login>bobjones@acme.com</login>  
        <is-member>true</is-member>  
    </principal>

// Ethnio survey code removed