DX NetOps

 View Only
Expand all | Collapse all

User addition using API

  • 1.  User addition using API

    Posted Jul 02, 2019 04:15 AM

    Hi All,

     

     I have created a user using API and it was working fine ,now I want to add the user in group directly while creating. How to do this .

     

    Creating user :  http://localhost:80/spectrum/restful/model?landscapeid=0x2400000&mtypeid=0x10004&attr=0x1006e&val=test_user

     

    Adding user in group:

     

    Command :

     

     http://localhost:80/spectrum/restful/associations/relation/0x10031/leftmodel/0x100016/rightmodel/0x285f0c8

     

    Model handle which  I have is used is Home model handle got from user -> advanced and user group -> advanced

    Error :

     

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

    <create-association-response

                    xmlns="http://www.ca.com/spectrum/restful/schema/response" error-message="The landscape 100000 does not exist." error="NoSuchLandscape"/>

     

    Kindly suggest .



  • 2.  RE: User addition using API

    Posted Jul 04, 2019 03:33 AM
    Any suggestions


  • 3.  RE: User addition using API

    Posted Jul 04, 2019 08:39 AM
    This will work to create a user and add to group at the same time.

    http://<HostName or IPAddress>:<port>/spectrum/restful/model?mtypeid=0x10004&parentmh=<UserGroup_ModelHandle>&relationid=0x10022&attr=0x1006e&val=<UserName>

    <HostName or IPAddress> --> Use either Host Name or IP Address of the OneClick Server.
    <port> --> Use the port Number here (Ex: 8080)
    <UserGroup_ModelHandle> --> Find out the User Group Model_Handle value and replace it
    <UserName> --> Replace it with the User ID/Name

    Here,
    mtypeid=0x10004 represents the modeltype_handle value for User model
    relationid=0x10022 represents the relation name "Has_Member"
    attr=0x1006e represents the Model_Name attribute

    Hope this helps.


    ------------------------------
    Thank you.
    Rajashekar
    ------------------------------



  • 4.  RE: User addition using API

    Posted Jul 04, 2019 08:42 AM
    Use the below POST method.

    http://<HostName or IPAddress>:<PortNumber>/spectrum/restful/model?mtypeid=0x10004&parentmh=<Model_Handle of UserGroup>&relationid=0x10022&attr=0x1006e&val=<UserName>

    Replace:
    <HostName or IPAddress> with OneClick server host name or IP Address.
    <Model_Handle of UserGroup> with model handle value of the User Group you want to add the user
    <UserName> with the User Name/ID you want to create

    ------------------------------
    Thank you.
    Rajashekar
    ------------------------------



  • 5.  RE: User addition using API

    Broadcom Employee
    Posted Jul 05, 2019 01:23 PM
    From the look of you original port:

    http://localhost:80/spectrum/restful/associations/relation/0x10031/leftmodel/0x100016/rightmodel/0x285f0c8

    The user model and user group model are in two different landscapes.

    From the docs:

    POST associations

    POST associations creates an association. A specific relation is created between two models. Only models on the same SpectroSERVER can be associated.


    Joe


  • 6.  RE: User addition using API

    Posted Jul 08, 2019 01:48 AM
    Hi Rajasekar ,

     Thanks it is working but it is getting created at MLS landscape . I want to specify the landscape .Tried this but not working 

    http://localhost:80/spectrum/restful/model?landscapeid=0x2400000mtypeid=0x10004&parentmh=0x284bae9&relationid=0x10022&attr=0x1006e&val=test1


  • 7.  RE: User addition using API

    Posted Jul 09, 2019 09:46 AM
    @Issac08 

    How many landscapes do you have?
    How are you taking the parentmh value?​

    ------------------------------
    Thank you.
    Rajashekar
    ------------------------------



  • 8.  RE: User addition using API
    Best Answer

    Posted Jul 09, 2019 09:46 AM
    Edited by Christopher Hackett Jul 09, 2019 04:48 PM
    It is working for me even if I mentioned landscape ID
    http://localhost:8080/spectrum/restful/model?landscapeid=0x400000&mtypeid=0x10004&parentmh=0x403f54&relationid=0x10022&attr=0x1006e&val=Rajashekar

    I see, you are missing & between landscapeid=0x2400000 and mtypeid=0x10004 

    Try the below...
    http://localhost:80/spectrum/restful/model?landscapeid=0x2400000&mtypeid=0x10004&parentmh=0x284bae9&relationid=0x10022&attr=0x1006e&val=test1


    Make sure to use the correct landscape ID and the parent model handle.

    Hope, you are getting the parent (UserGroup) model handle properly.

    Example:
    1. Under locator, click "Create New Search Button"
    2. Use the below attribute and attribute value to list the existing user groups --> Click on Launch (You can save the search criteria or just cancel)


    3. Select the user group you want to add the user --> Look for model_handle value under attributes of the model component detail pane.



    ------------------------------
    Thank you.
    Rajashekar
    ------------------------------



  • 9.  RE: User addition using API

    Posted Jul 10, 2019 09:15 AM
    Thanks it have worked ,made a mall mistake missed "&" after landscape id .

    What is the auto generated password for those user ids ? 
    I want to pass some inputs in general information  for full name , department ,notes ,contact section ,how can i add the attribute and pass it in same call?
    Kindly suggest


  • 10.  RE: User addition using API

    Posted Jul 11, 2019 10:47 AM
    Edited by Rajashekar Allala Jul 11, 2019 10:50 AM
    No Password is created for the model you create using the above method. You can set the password using the attribute id 0x11f9a using PUT method. However, it will only take the encoded format of the value (octet string). Not sure, how to generate it and pass it to that attribute in the PUT method.

    It is not possible to use the same method you use to create a model as updating the attributes use PUT method. Below is how you can update the attributes.

    http://<hostname><:portnumber>/spectrum/restful/model/<model_handle>?attr=<attr_ID>&val=<num>
    https://docops.ca.com/ca-spectrum/10-2-3/en/programming/web-services-api-reference/how-to-use-the-ca-spectrum-web-services-api/restful-resources-nouns/model#model-PUTmodel
    You can update multiple attributes at a time using the below format of PUT method.
    http://<hostname><:portnumber>/spectrum/restful/model/<model_handle>?attr=<attr_ID>&val=<num>&attr=<attr_ID>&val=<num>&............

    ------------------------------
    Thank you.
    Rajashekar
    ------------------------------



  • 11.  RE: User addition using API

    Posted Jul 11, 2019 11:26 AM
    Also, note that, if the Spectrum is integrated with LDAP/ SSO (CA EEM), no need to create password for users locally.

    ------------------------------
    Thank you.
    Rajashekar
    ------------------------------



  • 12.  RE: User addition using API

    Posted Jul 15, 2019 11:39 PM
    Hi Rajashekar,

    We have only local users ,spectrum is not integrated wth EEM or LDAP


  • 13.  RE: User addition using API

    Posted Jul 16, 2019 05:24 AM
    As I said in my last reply, the attribute supports only the octet string. So, not sure how we can pass the password information.
    Try to check with Spectrum support team to see if they can help on your query.

    ------------------------------
    Thank you.
    Rajashekar
    ------------------------------