AnsweredAssumed Answered

How to set authorizations for a client to a host using the UC4 API?

Question asked by d8a6cecdcd492f7750c693c1e9f4541a on Apr 22, 2016
Latest reply on Jul 13, 2016 by brendan_sapience_automic

I am trying to set Authorizations for a client to a Host using the UC4 API using the setHostAuthorization(int client, boolean read, boolean write, boolean execute) method and I can see that the authorizations are changing for the client in the auth object. But, when I save it, it does not seem to get updated in the actual host in client 0.

 

Here is the code  : 

UC4HostName lxb101hostName =newUC4HostName("AE-QA-LXB101");

OpenObject lxb101hostObject =newOpenObject(lxb101hostName);

engine.send(lxb101hostObject);

Host lxb101Host =newHost();

lxb101Host = (Host) lxb101hostObject.getUC4Object();

Authorizations auth = lxb101Host.authorizations();

booleanauthStatus = auth.setHostAuthorization(client,true,true,true);

SaveObject save1 =newSaveObject(lxb101Host);

String msg1 = engine.send(save1);

System.out.println("Status of authorizations is " + authStatus);

msg1 += engine.send(new  CloseObject(lxb101Host));

 

Here is the code for send()

publicString send(XMLRequest req)throwsIOException {

        connection.sendRequestAndWait(req);

       if(req.getMessageBox() !=null) {

            System.err.println(req.getMessageBox().getText());

            //System.exit(-1);

            String msg = req.getMessageBox().getText();

           returnmsg;

        } else{

              return" ";

        }

             

    }

  

Do I need to send anything else?

 

As an alternate approach, I also tried doing the same using SetHostAuthorizations. When I run this, I get the error/message - “Runtime error in object ' ', line '&02'. No select statement open - read invalid”and successCount and failureCount are 0. I think I would prefer the second approach because it lets me change it across a whole list of hosts. Can you give me some pointers on why I am getting the error with the second approach?

 

SetHostAuthorizations setAuth = new SetHostAuthorizations("AE*", client, true, true, true);

String msg = engine.send(setAuth);

int successCount = setAuth.getUpdateCount();

int failureCount = setAuth.getFailedCount();

 

Thanks!

Outcomes