By hawkeye217 on
Anyone familiar with a module or way of assigning a role based on an incoming IP address?
I've read around and seen some hacks for user.module, but I'd rather not go that route if there's something cleaner or something I'm not seeing!
Comments
plz check it in the module list
Suggest you check the module lists,perhaps you can find it.
GL
Welcome to http://www.cheapmesos.com/
Welcome to http://www.vanguardsagaofhero.com/
I did... And didn't see
I did... And didn't see anything that would do what I was looking for - hence the forum post in case anyone else knew something I didn't!
Drupal is amazing, so I am sure it's possible...
How to force users from outside the local network to Log In
Here's a solution for a variation of this request. (This was done for Drupal 4.7.6.)
We wanted users in our local network to be able to come to our Drupal site and be treated as Anonymous logins, with the option to log in to do editing. We wanted users coming in from the internet to register and log in before they could see any content. It was not so obvious how to do this.
First, I renamed page.tpl.php (in my custom theme) and created a new one, like this:
Then I added the following to includes/common.inc:
Which you can customize to select which IP addresses you want to allow.
And finally, I used the pih_authorized() function to hide blocks in the left sidebar, except for the Login block.
This seems to work, and aside from the code added to common.inc, it should survive a software upgrade. I suppose there is a better place to put that code other than common.inc.
-md
Additional notes
1) The solution I proposed above is probably dependent on using the phptemplate theme engine.
2) You should also set $head_title to set the title for the resulting page.
-mark
this same thing for v6
i want exactly this . to force login for people from outside of a set ip range. will this work for v6 ?
Diana Castillo
Possible, but
I'm pretty sure I could write that as a module. Would simply check the users IP address on login and add/remove configured 'role' to the user depending on his IP address.
What I'm wondering is how configurable do you think it should be?
Do you wan't to match an IP address to a single address, a list or simply a netmask (like 192.168.0.0/24) ?
I'm asking because I think I could use this module myself for an Intranet website I'm currently working on. So if we have similar needs, that would be beneficial for you :)
either one...
Either one, a netmask or individual IPs... I could easily modify any php, I'm just not familiar with a module's hooks into core to be able to write one myself :)
Let me know what you think and if I can be of any help!
Any progress...?
Any progress...?
Not much
I've been busy with school but it got canceled due to snow so I took a look today.
I'm still scoping and doing groundwork but so far the plan is:
Completion is around 30% right now. I'll keep you posted.
Cool.
Sounds good.
I'm actually looking to assign more of a subset of the "anonymous" role, without someone having to log in. I want to display specific blocks and menu items based on how somebody reaches the site. Does that make sense?
If you could write it for yourself keeping my situation in mind (so I can easily modify it to assign the role without a user logging in) that would be awesome!
also interested
We're also looking for (and are willing to write / help write) a module that allows anonymous users from a range of IP addresses access to view pages, but requires anonymous users from all other IP addresses to log in first. I'd love to know if anyone else is interested / has been working on this sort of thing.
The troll module looks like it might contain relevant bits, but I haven't looked in detail yet.
----
Steve McCullough, PhD
:: Drupal . Web . DevOps . Linux
:: http://irrational.ca
Interested as well...
I would also find this module useful for a project that I'm currently working on.
Cheers!
Not sure how
If anyone knows how to extend the anonymous user or add a role to an anonymous user that would be great. With my limited knowledge of the Drupal API I'm only able to add roles to registered users.
On hold...
I've put this on hold for a while for several reasons.
If someone else decides to go ahead and create this I have some comments.
Thanks for trying..
I don't have any time to work on it now either, but thanks for trying... Anyone else want to give it a try?
Look at IPAuthenticator -
Look at IPAuthenticator - seems to be what you're looking for.
ipAuthenticator
it seems that module assigns users to IPs, not roles to IPs