How to use checkAcl method in ServerAPI class

Hi,
I want to check if login-user has an access permission to some IS service using ACLs setting in webMethods Administrator page.

The actions I have done are as follows

1.add user monUser, group monGroup
2.set monUser to be belong to monGroup
3.add Acls monAcl
4.set monGroup to be associated for monAcl

then I made a java service like

// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
String userid = IDataUtil.getString( pipelineCursor, “username” );
String aclname = IDataUtil.getString( pipelineCursor, “aclname” );
pipelineCursor.destroy();

ServerAPI sa = new ServerAPI();
ValuesEmulator.put(pipeline, “hasPermission”, (sa.checkAcl(aclname,userid)) ? “Y” : “N”);

When I test with userid:monUser, aclname:monAcl, but it returns ‘N’.
I don’t know what’s wrong about it.

Your help will be appreciated. Thanks in advance. :slight_smile:

I tested with following code,

// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
String aclname = IDataUtil.getString( pipelineCursor, “aclname” );
pipelineCursor.destroy();

// Check current user is belong to acl group
String userid = InvokeState.getCurrentUser().getName();
ValuesEmulator.put(pipeline, “isMonitorUser”, (ServerAPI.checkAcl(aclname,userid)) ? “Y” : “N”);

It works fine. :-<
checkAcl() has two string type parameters.
What I don’t understand is that the result is different in two cases.

1.case 1

aclname : “monAcl
userid : “monUser (string) → displayed at Developer Results windows

ServerAPI.checkAcl(aclname,userid) : N

2.case 2

aclname : “monAcl” (string)
userid : InvokeState.getCurrentUser().getName(); monUser (string)

ServerAPI.checkAcl(aclname,userid) : Y

Is there good explanation about this?

Salut,

Have you inverted the result ?
I think case 1 should be Y and case 2 should be N

and how do you test your case 2 ? with developer using the “monUser” account ?
print the result of ‘InvokeState.getCurrentUser().getName();’ to be sure it is “monUser”.
→ It’s working fine with your example in my 6.5 IS. :slight_smile: