Using REST to create a new user with a user group on a DSS environment
search cancel

Using REST to create a new user with a user group on a DSS environment

book

Article ID: 260987

calendar_today

Updated On:

Products

Spectrum Network Observability

Issue/Introduction


We would like to create a new user in a DSS environment using REST.  However we see errors "already exists" when we try to create the user.

 

The following message is expected from Spectrum:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<create-model-response xmlns="http://www.ca.com/spectrum/restful/schema/response" error="AlreadyExists">
  <model mh="0xa873b6"/>
</create-model-response>

Environment

DX Netops Spectrum

Cause

When creating a user in a DSS environment under a user group, you need to have the domain id of the User Group included (converted to hex) in the query.

Resolution

The first query is returning model_handle and DomainID (Landscape Handle) of the user-group.
 
               You will need to use these values and create the user under the user-group.
 
               As an example :
 
STEP-1 : Fetching the Model_Handle and DomainID of the User-Group Administrator:
 
POST https://<ONECLICK HOSTNAME>:<port>/spectrum/restful/servicesinfo/serviceslist/spectrum/restful/models
 
<rs:model-request throttlesize="500"
  xmlns:rs="http://www.ca.com/spectrum/restful/schema/request"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.ca.com/spectrum/restful/schema/request ../../../xsd/Request.xsd">
    <rs:target-models>
      <rs:models-search>
        <rs:search-criteria xmlns="http://www.ca.com/spectrum/restful/schema/filter">
          <filtered-models>
            <and>
                <equals>
                    <attribute id="AttributeID.MTYPE_HANDLE">
                        <value>0x1040a</value>  <!--UserGroup -->
                    </attribute>
                </equals>
                <equals>
                    <attribute id="0x1006e">    <!--Model_Name -->
                        <value>Administrator</value>
                    </attribute>
                </equals>
            </and>
          </filtered-models>
        </rs:search-criteria>
      </rs:models-search>
    </rs:target-models>
    <rs:requested-attribute id="0x129fa" /> <!--Model Handle --> No need to fetch Home Model Handle here, just fetch its own model_handle
    <rs:requested-attribute id="0x129ac" /> <!—DomainID of the User-Group -->
</rs:model-request>
 
Reponse:
 
<model-response-list total-models="2" throttle="2" error="EndOfResults" xmlns="http://www.ca.com/spectrum/restful/schema/response">
   <model-responses>
      <model mh="0xb00068">
         <attribute id="0x129fa ">0xb00068</attribute> <!-- ModelHandle -->
         <attribute id="0x129ac">11534336</attribute> <!—DomainIDof the User-Group -->
      </model>
      <model mh="0xa0007a">
         <attribute id="0x129fa ">0xa0007a</attribute> <!-- ModelHandle -->
         <attribute id="0x129ac">10485760</attribute> <!—DomainID of the User-Group -->
      </model>
   </model-responses>
</model-response-list>
 
              
STEP-2: Convert the Decimal value of DomainID received above to Hexa-Decimal value
               Decimal Value: 11534336               Hexa-Decimal Value: 0xB00000
               Decimal Value: 10485760               Hexa-Decimal Value: 0xA00000
 
 
STEP-3: Create the user under Administrator group on both the landscapes with 2 separate queries

POST 
https://<ONECLICKHOSTNAME>:<port>/spectrum/restful/servicesinfo/serviceslist/spectrum/restful/model?landscapeid=0xB00000&mtypeid=0x10004&parentmh=0xb00068&relationid=0x10022&attr=0x1006e&val=spectrum <!— creates the user spectrum on domain 0xB00000  -->

POST https://<ONECLICKHOSTNAME>:<port>/spectrum/restful/servicesinfo/serviceslist/spectrum/restful/model?landscapeid=0xA00000&mtypeid=0x10004&parentmh=0xa0007a&relationid=0x10022&attr=0x1006e&val=spectrum <!— creates the user spectrum on domain 0xA00000  -->