Forcing an anonymous user into a role

beekerstudios - December 10, 2007 - 18:57

I was thinking that I could set a users role based on the users IP or a URL they go to, say via an e-mail link that was sent out or something, and then use nodeaccess module to control access to certain nodes based on their role.

Here is the problem. How can I actually set the user's role, how do I show the user as "being logged" in, and how do I make sure that nodeaccess is checking the set role properly.

I tried doing something like this:

$GLOBALS['user']->roles[sizeof($GLOBALS['user']->roles)+2] = "anonymous KNOWN IP";

However I think node access doesn't check the $GLOBALS['user'] array, it just checks the user ID and then looks up in the DB if that user is in a role.

Do I need to force them into a logged in user account that is within a role?

This is part of an intranet type of schema, where I want a very large pool of users to be able to view certain nodes but not the whole world.

I know there are issues of IP spoofing, but this is a fairly low security level type of situation. No NDA information or anything.

The system knows how to

keylope - December 10, 2007 - 20:00

The system knows how to distinguish between anonymous and authenticated users. If you want to create different roles, you should probably create roles for authenticated users. I believe there is a module that can create roles and assign roles during registration.

I haven't seen anyway to create roles for anonymous users.

Hope that helps.

User Roles

Steve Halleman - December 10, 2007 - 20:47

Take a look at http://drupal.org/project/logintoboggan. This may have what you are looking for.

Steve Halleman

Unfortunately

beekerstudios - December 11, 2007 - 00:24

I am not sure what this has to offer me... it seems like a well supported module, but I think it's not what I am looking for.

Thanks!

Well here's the problem

beekerstudios - December 11, 2007 - 00:21

I want two "roles" of anonymous users. I know it can tell if a users is anonymous, but using it conjunction with nodeaccess where I can limit access to specific "roles" to specific nodes means I have to put the other "anonymous users" into a "role" and give access to nodes to that role.

Let's look at it this way.

There is the whole world... and they are "anonymous", and then there is a subset of users and I without a doubt know that they will have a specific ip address in a specific range of ip's, but I don't want to require them to be logged in just to see a node.

I want to make it very easy for this known user pool to access node's I give them access to.

So my plan of attack was to set a role or user id if someone had a specific ip address and wasn't logged in already. I called this the "Anonymous KNOWN", meaning I know they should have access I just don't want them to have to log in or even realize they are "logging in", I also don't know who they are what their e-mail account is, or anything like that, and I don't care.

It seems like what i really need is some combination of node access and an intranet module all put together. That's really what I am after, I was just willing to kludge something together to get it to work and then possibly find a solution if someone found it. I have seen some talk about this, but nothing set in stone.

Subscribing... This is

joachim - January 31, 2008 - 18:11

Subscribing...

This is exactly what I need to do too: I have a private site that I want people to be able to log in to from home, and use in the building without logging in. So basically, anonymous users from a particular IP need to be recognized and given a role.

Hi, maybe this:

thePanz - May 8, 2008 - 18:03

Hi, maybe this: http://drupal.org/project/ipAuthenticator is what are you looking for... it's quite new, check it before go to public site!

Regards!

-thePanz-

Hi, maybe this:

thePanz - May 8, 2008 - 18:04

Hi, maybe this: http://drupal.org/project/ipAuthenticator is what are you looking for... it's quite new, check it before go to public site!

Regards!

-thePanz-

Eureka!

beekerstudios - May 15, 2008 - 21:01

I totally forgot about this thread, but I posted something on the nodeaccess module in regards to it:

http://drupal.org/node/213867

Wondering if that ipAuthenticator resolved the login loop issue I had to solve as well.

It would seem that this is a good out of the box solution, and using it in conjunction with nodeaccess, gives you really granular control.

 
 

Drupal is a registered trademark of Dries Buytaert.