cancel
Showing results for 
Search instead for 
Did you mean: 

How to update SAP EP IUserAccount SecurityPolicy UME users

0 Kudos

Hi,

The below is our current code, which is running successfully to create new test users with

SecurityPolicy to default .

IUserMaint newUser = userfact.newUser(PortalID);
newUser.setFirstName(Firstname);
newUser.setLastName(Lastname);
newUser.setEmail(EmailID);
Locale PortalLang = new Locale("en");
newUser.setLocale(PortalLang);
newUser.save();
newUser.commit();
IUserAccount useracc = UMFactory.getUserAccountFactory().newUserAccount(PortalID,
newUser.getUniqueID());
useracc.setPassword(NewUserPWD);
useracc.save();
useracc.commit();


Now we a have new scenario that while creating new users we need to update the user type to Technical User (Security Policy).

I don't see that property or method is not available to use in the code(setSecurityPolicy

(com.sap.security.api.*))

Have referred the below link but the below method is not available to use.

https://archive.sap.com/discussions/thread/1876052#


Eg.

IUserAccount userAccount = accountFactory.getMutableUserAccount(<UNIQUE ID OF USER>);

userAccount.setSecurityPolicy("<SECURITY POLICY>"); //In my case I'm changing it to technical

userAccount.save();

userAccount.commit();

Please help to suggest, how we can update the user type to Technical User using the code.

What are the other ways of achieving this scenario.

Thanks, SMSVikasK

Accepted Solutions (1)

Accepted Solutions (1)

nickrankin
Contributor

Hi Vikas,

Have you tried using 'SECURITY_POLICY_TYPE_TECHNICAL' constant instead of simply technical, e.g:

userAccount.setSecurityPolicy(IUserAccount.SECURITY_POLICY_TYPE_TECHNICAL);


Best regards,

Nick

Answers (2)

Answers (2)

0 Kudos
Thanks a lot 🙂 .

It worked perfectly. The jar was having the required methods com.sap.security_2.0.0.110922073749.jar.

NWDS Code:

useracc.setSecurityPolicy(IUserAccount.SECURITY_POLICY_TYPE_TECHNICAL);

Complied :

useracc.setSecurityPolicy("technical");

Thank you. SMSVikasK

0 Kudos

Hi Nick,

Thanks for your reply.

We are using SAP EP 7.4 SPS12, We have referenced the jar (com.sap.security.api.*) and trying to find the methods you told to use. buts its not available to use. I can see other properties but not the below.

userAccount.setSecurityPolicy(IUserAccount.SECURITY_POLICY_TYPE_TECHNICAL);

Are you able give code samples having code properties of this *setSecurityPolicy*

what version your are referring to where this method is there.

Thanks

SMSVikasK

nickrankin
Contributor

Hi Vikas,

The IUserAccount interface is inside <nwds-dir>\eclipse\plugins\com.sap.security_<version>.jar. You should be ok once you add the .jar to your project build path.


If you continue to get build errors please provide the stack trace


Best regards,

Nick