CodeIgniter Forums
Using Windows authentication - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Using Windows authentication (/showthread.php?tid=55598)



Using Windows authentication - El Forum - 11-02-2012

[eluser]jprateragg[/eluser]
I'm looking at porting our existing application to CodeIgniter. Our application currently runs on Windows server. The application doesn't have a formal login system--it captures the $_SERVER['AUTH_USER'] of the currently logged in user, queries the database for a matching user name, then creates and loads session data indicating the user is logged in. Is there a way to mimic that with CodeIgniter? I've created a login controller, but I don't know how to get the $_SERVER['AUTH_USER'] to it since it's not accessible within the class. I appreciate any help. Thanks!


Using Windows authentication - El Forum - 11-02-2012

[eluser]jprateragg[/eluser]
I created a custom config file (config2.php) and added the following line to it:

Code:
$config['user'] = $_SERVER['AUTH_USER'];

I was able to access it through all of my controllers so I think this will do the trick. Is there a better way to do this or should this work fine? Thanks!


Using Windows authentication - El Forum - 11-02-2012

[eluser]Patrick Spence[/eluser]
[quote author="jprateragg" date="1351889051"]I created a custom config file (config2.php) and added the following line to it:

Code:
$config['user'] = $_SERVER['AUTH_USER'];

I was able to access it through all of my controllers so I think this will do the trick. Is there a better way to do this or should this work fine? Thanks![/quote]

the input class encapsulates the server variable.

http://ellislab.com/codeigniter/user-guide/libraries/input.html

specifically $this->input->server('AUTH_USER') should do what you need to get the data.

You could easily write a library that grabs that and encapsulates the verification and session management as well.



Using Windows authentication - El Forum - 11-03-2012

[eluser]jprateragg[/eluser]
[quote author="Patrick Spence" date="1351911376"]the input class encapsulates the server variable.

http://ellislab.com/codeigniter/user-guide/libraries/input.html

specifically $this->input->server('AUTH_USER') should do what you need to get the data.

You could easily write a library that grabs that and encapsulates the verification and session management as well.
[/quote]
Ah! That works well too! I never thought about that. I'm still new to CodeIgniter and after reading the manual once I haven't been able to retain everything yet. Smile


Using Windows authentication - El Forum - 11-03-2012

[eluser]Patrick Spence[/eluser]
[quote author="jprateragg" date="1351979305"][quote author="Patrick Spence" date="1351911376"]the input class encapsulates the server variable.

http://ellislab.com/codeigniter/user-guide/libraries/input.html

specifically $this->input->server('AUTH_USER') should do what you need to get the data.

You could easily write a library that grabs that and encapsulates the verification and session management as well.
[/quote]
Ah! That works well too! I never thought about that. I'm still new to CodeIgniter and after reading the manual once I haven't been able to retain everything yet. Smile[/quote]

Yeah, I still find more things all the time in there as I come up with new projects to work on. Smile