/[drupal]/contributions/modules/webserver_auth/webserver_auth.module
ViewVC logotype

Contents of /contributions/modules/webserver_auth/webserver_auth.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.12 - (show annotations) (download) (as text)
Fri Apr 29 19:27:31 2005 UTC (4 years, 7 months ago) by weitzman
Branch: MAIN
Changes since 1.11: +7 -1 lines
File MIME type: text/x-php
update for bootstrap changes in 4.6
1 <?php
2 // $Id: webserver_auth.module,v 1.11 2004/11/24 22:03:33 dries Exp $
3
4 function webserver_auth_init() {
5 global $user, $account;
6
7 if ($user->uid) {
8 //do nothing because user is already logged into Drupal
9 }
10 else {
11 if ($name = $_SERVER["REMOTE_USER"]) {
12 // user is logged into webserver.
13 $account->name = $name;
14 //modules get to change the user bits before saving. use a global $account to do so.
15 // only loaded modules will see this hook
16 module_invoke_all("webserver_auth");
17 // if we are in bootstrap, load user.module ourselves
18 if (!module_exist('user')) {
19 drupal_load('module', 'user');
20 }
21
22 // try to log into Drupal. if unsuccessful, register the user
23 $user = user_external_load($account->name);
24 if (!$user->uid) {
25 if (variable_get("user_register", 1) == 1) {
26 $user_default = array("name" => $account->name, "pass" => "cyan", "init" => db_escape_string($name), "authname_webserver_auth" => $account->name, "status" => 1, "roles" => array(_user_authenticated_id()));
27 // TODO - the hook_user('register') will fire but only for loaded modules. cold be a problem for sites using page cache and that hook+operation
28 $user = user_save("", array_merge($user_default, $account));
29 watchdog("user", "new user: $user->name (webserver_auth)", l(t("edit user"), "admin/user/edit/$user->uid"));
30 }
31 }
32 }
33 else {
34 // do nothing. user isn't logged into web server
35 }
36 }
37 }
38
39 // using a global to change your bits. module_invoke_all miffs me.
40 function webserver_auth_webserver_auth() {
41 global $account;
42
43 // pretties up the username for NTLM authentication (i.e. Windows)
44 if ($_SERVER["AUTH_TYPE"] == "NTLM" || $_SERVER["AUTH_TYPE"] == 'Negotiate') {
45 $account->name = substr(trim($account->name), strrpos(trim($account->name), "\\")+1);
46 }
47
48 if ($domain = variable_get("webserver_auth_domain", "")) {
49 if ($account->name) {
50 $account->mail = $account->name. "@$domain";
51 }
52 }
53 }
54
55 function webserver_auth_settings() {
56 $output = form_textfield(t("Email Domain"), "webserver_auth_domain", variable_get("webserver_auth_domain", ""), 30, 55, t("Append this domain name to each new user in order generate his email address."));
57 return $output;
58 }
59
60 function webserver_auth_help($section) {
61 $output ="";
62
63 switch ($section) {
64 case 'admin/help#webserver_auth':
65 break;
66 case 'admin/modules#description':
67 $output .= t("Use web server authentication instead of Drupal");
68 break;
69 }
70
71 return $output;
72 }
73
74
75 ?>

  ViewVC Help
Powered by ViewVC 1.1.2