Hi all,

I've been struggling with DataSourceUserManager for the past week or so, and

could really use some help. I'm running out of ideas, if anyone can help me

get this last piece figured out, I will create a complete document for

OrionSupport detailing how DataSourceUserManager works, and hopefully stop

these types of questions from floating through here again (how's that for

incentive!)

The problem is occurring when I try to add a user to a role, and Oracle is

kicking back the following error message:

SQL error: ORA-01008: not all variables bound

This looks to me like a problem with the generated SQL code from Orion.



The version of Orion is 1.3.8 and the database is Oracle 8.1.7 Release 2.

The DataSourceUserManager is using two tables for authentication, one to

verify the user and password, and then another to perform the role mappings

for each user.

I can verify a user, their password and their roles. This works with users

that only have one role and users that have more than one role. All the

users are being permitted and restricted properly.

The problem is adding a user to a role. I am trying to do this using a

Servlet that just creates a user and adds them to a role using the

RoleManager.

e.g. a user logs in with Tod / test and then the Servlet runs and tries to

create a user, Bob / test. Then Bob is added to the role "users".

I get this error from the Servlet when trying to execute the method

addToRole(principal, "users"). I am logging in with the user Tod, who has

permission to run the servlet.



Here is the code to add a user to the role:

=====================================================================

// Handles the HTTP GET request

public void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException

{

Principal principal;

ServletOutputStream out = response.getOutputStream();

response.setContentType("text/html");

out.println("<HTML><BODY>");

out.println("<P>About to add a new user named Bob");

System.out.println("Starting the addition of a new user.");

try {

RoleManager roleManager = (RoleManager) new

InitialContext().lookup("java:comp/RoleManager");

// This will create a user.

principal = roleManager.createPrincipal("Bob","test");

// This is where the user should be added to the role "users"

roleManager.addToRole(principal, "users"); // this is where bad

things happen

roleManager.store();

} catch (Exception e) {

System.out.println("bad things happened!");

e.printStackTrace();

}

}



If I run this code, I see the following on the output:

=====================================================================

Starting the addition of a new user.

DataSourceUserManager.getUser(Bob)

I have gotten a reference to the principal.

bad things happened!

java.lang.RuntimeException: SQL error: ORA-01008: not all variables bound

at com.evermind.sql.DataSourceUser.addToGroup(JAX)

at com.evermind.server.he.addToRole(JAX)

at TodServlet.doGet(TodServlet.java:65)

at javax.servlet.http.HttpServlet.service(HttpServlet.java)

at javax.servlet.http.HttpServlet.service(HttpServlet.java)

at javax.servlet.http.HttpServlet.service(HttpServlet.java)

at com.evermind.server.http.d1.si(JAX)

at com.evermind.server.http.d1.forward(JAX)

at com.evermind.server.http.ed.sp(JAX)

at com.evermind.server.http.ed.so(JAX)

at com.evermind.util.f.run(JAX)

=====================================================================



If I open up Oracle, the user was successfully added to the users table, but

the role mapping was not set up.

Here's the configuration from the orion-application.xml file:

<user-manager class="com.evermind.sql.DataSourceUserManager">

<property name="dataSource" value="jdbc/DefaultDS" />

<property name="table" value="MEMBEREJB"/>

<property name="usernameField" value="MEMBERNAME" />

<property name="passwordField" value="PASSWORD" />

<property name="defaultGroups" value="guests" />

<property name="groupMembershipTableName" value="MEMBER_GROUPS" />

<property name="groupMembershipUsernameFieldName" value="MEMBERNAME" />

<property name="groupMembershipGroupFieldName" value="MEMBERROLE" />

<property name="staleness" value="3600" />

<property name="debug" value="true" />

</user-manager>



Any help to shed some light on this would be much appreciated. It would be

nice to see this documented finally...

Thanks

Lawrence.








Reply via email to