cancel
Showing results for 
Search instead for 
Did you mean: 

How to access KM folder with self-creation service user?

Former Member
0 Kudos

Dear All,

I have added a new service user i"contract_service" in the following two places:

1) UM

2)System Administration->System Configuration->(In detail Navigation)Knowledge Management->Content Management and in configuration iview go to Utilities->System Principals->System User

An exception arrises when I try to create a KM folder with "contract_serive" user.

The exception is as follows:<b>com.sapportals.portal.security.usermanagement.UserManagementException: Could not get service user "contract_service".</b> at com.sapportals.portal.security.usermanagement.ServiceUserFactoryImpl.getServiceUser(ServiceUserFactoryImpl.java:54) at com.sap.dc.AttachmentCompInterface.CreateKMFolder

I used the following piece of codes to get service user...

private static final String CONTRACT_SERVICE_USER = "contract_service";

//create an user object from the current user

com.sapportals.portal.security.usermanagement.IUser serviceUser = WPUMFactory.getServiceUserFactory().getServiceUser(CONTRACT_SERVICE_USER);

Can anyone point out where I may do wrongly?

thanks,

Zita

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi All,

No body answered me!

I have created the service user programmly by using the piece of code:

private static final String CONTRACT_SERVICE_USER = "contract_service";

try{

serviceUser =(com.sap.security.api.IUser) AccessController.doPrivileged

(

new PrivilegedExceptionAction()

{

public Object run() throws UMException

{

IUserManagementEngine umService = (IUserManagementEngine)

PortalRuntime.getRuntimeResources().getService(

IUserManagementEngine.KEY );

IServiceUserFactory userFactory = umService.getServiceUserFactory();

com.sap.security.api.IUser user = null;

try

{

userFactory.createServiceUser(CONTRACT_SERVICE_USER );

user = (com.sap.security.api.IUser)userFactory.getServiceUser

(CONTRACT_SERVICE_USER );

}

catch (UMException ex)

{

StringWriter sw = new StringWriter();

PrintWriter pw = new PrintWriter(sw);

ex.printStackTrace(pw);

String str = sw.toString();

}

return user;

}

}

);

}

catch (PrivilegedActionException ex)

{

StringWriter sw = new StringWriter();

PrintWriter pw = new PrintWriter(sw);

ex.printStackTrace(pw);

String str = sw.toString();

}

return serviceUser;

}

I also create this "contract_service" in the following two places:

1) UM

2)System Administration->System Configuration->(In detail Navigation)Knowledge Management->Content Management and in configuration iview go to Utilities->System Principals->System User

But when I tried to print out something like this "user.getFirstName()"....I got an "null pointer exception". Funny thing is that I did not get any exception in the line "userFactory.createServiceUser(CONTRACT_SERVICE_USER );"

I used this created user name to create a KM folder and the modified name showed "anonymous".

Can anyone kindly tell me or share with me your experieces in creating a service user?

thanks alot,

Zita

Former Member
0 Kudos

Hi Zita,

Do you import the right class : <b>com.sap.security.api.UMFactory</b>

Could you refer the post. /message/2919633#2919633 [original link is broken]

Regards,

Rick Ni

Former Member
0 Kudos

Hi All,

No body answered me!

I have created the service user programmly by using the piece of code:

private static final String CONTRACT_SERVICE_USER = "contract_service";

try{

serviceUser =(com.sap.security.api.IUser) AccessController.doPrivileged

(

new PrivilegedExceptionAction()

{

public Object run() throws UMException

{

IUserManagementEngine umService = (IUserManagementEngine)

PortalRuntime.getRuntimeResources().getService(

IUserManagementEngine.KEY );

IServiceUserFactory userFactory = umService.getServiceUserFactory();

com.sap.security.api.IUser user = null;

try

{

userFactory.createServiceUser(CONTRACT_SERVICE_USER );

user = (com.sap.security.api.IUser)userFactory.getServiceUser

(CONTRACT_SERVICE_USER );

}

catch (UMException ex)

{

StringWriter sw = new StringWriter();

PrintWriter pw = new PrintWriter(sw);

ex.printStackTrace(pw);

String str = sw.toString();

}

return user;

}

}

);

}

catch (PrivilegedActionException ex)

{

StringWriter sw = new StringWriter();

PrintWriter pw = new PrintWriter(sw);

ex.printStackTrace(pw);

String str = sw.toString();

}

return serviceUser;

}

I also create this "contract_service" in the following two places:

1) UM

2)System Administration->System Configuration->(In detail Navigation)Knowledge Management->Content Management and in configuration iview go to Utilities->System Principals->System User

But when I tried to print out something like this "user.getFirstName()"....I got an "null pointer exception". Funny thing is that I did not get any exception in the line "userFactory.createServiceUser(CONTRACT_SERVICE_USER );"

I used this created user name to create a KM folder and the modified name showed "anonymous".

Can anyone kindly tell me or share with me your experieces in creating a service user?

thanks alot,

Zita