|
|
|
Joined: 6/17/2004
Posts: 10
|
|
|
Hi,
We are running into an incredibly strange problem, which I hope is just a configuration oversight somewhere. Here's the issue:
2 computers, 1 is an XP development machine, the other is a Windows 2003 server.
Both have copies of DNN4.3.7 installed.
When an user logs in for the first time, we check a third party database and create the DNN user and roles that they should be assigned to programmatically using the following code to add a number of roles to their account
private
{
RoleInfo ri = rc.GetRoleByName(0, roleName);
try
{
rc.AddUserRole(
Synch.DNNPortalID,
userID, ri.RoleID,
DotNetNuke.Common.Utilities.Null.NullDate);
}
}
The user is then immediately logged in using
DotNetNuke.Entities.Users.UserController.ValidateUser(Synch.DNNPortalID, tbLogin.Text,
tbPassword.Text, "", Synch.DNNPortalName, Request.UserHostAddress, ref loginStatus);
DotNetNuke.Entities.Users.UserInfo objUser =
When the above code is run, and you go to look in the database, the roles seem to be there. However, when the user logs into the Win 2003 box, they are not given their proper permissions based on the roles we assigned them. Works fine on the XP deployment.
And it get stranger...to help debug, we built a simple module to display to the user all the roles they are a part of, using code like this:
DotNetNuke.Security.Roles.RoleController rc =
new DotNetNuke.Security.Roles.RoleController();
ArrayList roles = rc.GetRoles();
DotNetNuke.Entities.Users.UserController um =
new DotNetNuke.Entities.Users.UserController();
DotNetNuke.Entities.Users.UserInfo ui =
um.GetUserByUsername(Synch.DNNPortalID, loginname);
if (ui != null)
{
int uid = ui.UserID;
string[] rr = rc.GetPortalRolesByUser(uid, Synch.DNNPortalID);
Label1.Text="";
foreach (string r in rr)
Label1.Text += r +"<br>";
Label1.Text += "--" + "<br>";
if (ui.Roles != null)
{
rr = ui.Roles;
foreach (string r in rr)
Label1.Text += r + "<br>";
}
}
Now, when the user logs in, then navigates to the page with the above module on it, their appropriate roles are displayed. However, from the Windows 2003 box, only the Subscriber and Registered Users is displayed. BUT, if we wait about 10 seconds, then go to refresh this page, their roles eventually show up, even though they are still not provided access to the information provided by their role!! Remember, the user had to navigate to this page in the first place, so it isnt an obvious caching issue.
Does anyone have any clue what is going on here? Is there some caching issue going on? We've been running this code perfectly in DNN3.X for over a year now, and it works great on the XP development environment, but gets very strange on that Windows 2003 box.
Help! please! I'm pulling my hair out on this one.
take care,
jasen
static void giveDNNRoleToDNNUser(int userID, string userName, string roleName)RoleController rc = new RoleController();
|
|
|
|
| |
|
|
Joined: 6/17/2004
Posts: 10
|
|
|
Ok, much easier way to explain the above problem after more investigation:
1) programmatically remove and add roles to user.
2) immediately log that user in
Result: user is not assigned the proper roles for up to 10-20 seconds, which by then is too late because they aren't given access to anything.
Now:
1) programmatically remove and add roles to user
2) put a breakpoint in and wait there for 10-20 seconds
3) continue with programmatic login
Result: works great. User has access to everything they need.
I have tried adding the following code:
DotNetNuke.Common.Utilities.DataCache.RemoveCache("GetTabPermissionsByPortal");
Response.Cookies["portalroles"].Expires = DateTime.Now.AddDays(-1);
Response.Cookies[".ASPXROLES"].Expires = DateTime.Now.AddDays(-1);
But that is not working either.. we have a custom login box, the user enters their information, we programmatically change the roles, log them in with ValidateUser, then redirect them to the proper page. I'm not sure what's going on here, but I somehow need to get their new roles activated immediately before my redirect to their home page.
thanks,
jasen
|
|
|
|
| |
|
|
Joined: 6/17/2004
Posts: 10
|
|
|
Hi again,
I know its the holiday season, but does anyone have any insight into this problem? Adding a user to a role is not activated for approximately 10-15 seconds (looks like some kind of caching issue). The problem is, and I can imagine a lot of people building large systems around DNN have the same problem, we log the person in immediately after assigning them to a role.
Right now the only workaround is completely unacceptable: we have to put a 10 second pause in after we assign the role but before we log them in.
Any help or insight would be really really appreciated. Even if someone can just tell me where the user roles are cached or what timer is used to refresh it every 10 seconds or so, perhaps there's a way to force the reload.
HELP, PLEASE!
take care,
Jasen
|
|
|
|
| |
|
|
Joined: 9/27/2005
Posts: 89
|
|
|
I am having the exact same problem where user roles are not recognised for about 20 seconds.
I have a long 4 step registration process on a website. I register users to DNN site in step one getting default registration info. At this stage user is assigned a security role called "Incomplete Registration". Once user finishes step 4 which is a custom module, Incomplete Registration role is removed, "Pending Approval" roles is assigned and user is directed to home page. On home page however the message shown to user is still the one that is only visible to "Incomplete Registration"...after 20 seconds approx. the appropriate message for security role Pending Approval is displayed.
The process worked fine in DNN 3...i am only having this issue after upgrading to DNN 4.4. I am using the following function to add and remove security role:
AddRemoveUserRole(UserId, UserInfo.Username, "IncompleteRegistration", "PendingApprovals", originalAppName, 1)
|
|
|
|
| |
|
|
Joined: 6/17/2004
Posts: 10
|
|
|
Hi Arifshah,
I have gotten a number of other personal emails since posting this with people having the same problem, asking me if I had a solution. Unfortunately, no one seems able to explain or help. Quite the conundrum.
Good luck! please let us know if you get it figured out.
take care,
jasen
|
|
|
|
| |