Help Desk Software & Beyond
February 04, 2012, 03:23:05 AM *
Welcome, Guest. Please login or register.
To post messages you need to register. We apologize for inconvenience, but this is to prevent spam.
Registration is instant (no email verification) and we do not ask for any personal information.

Login with username, password and session length
News: Welcome to Help Desk Software forum!
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: [MOD] Use Active Directory Login  (Read 3710 times)
mhequipit
Full Member
***

Karma: 1
Posts: 117


View Profile
« on: October 26, 2007, 11:40:19 AM »

Don't know if someone has already asked this, but is there a way to use Active Directory users instead of the internal users.cgi?  If not, can you send me a quote?
Logged
bbell
Newbie
*

Karma: 3
Posts: 29


View Profile
« Reply #1 on: October 24, 2008, 12:28:05 PM »

I know this is an old post, but came across the thread when I was looking for something else and figured I'd post an answer anyway.

I managed to get this working by adding a new file TTXLdap.pm:

Code:
package TTXLdap;

$TTXDropdown::VERSION='1.00';

use strict;
use Win32::OLE;

my $strADsPath = 'LDAP://substitute-your-primary-AD-server-here';
my $strADsAlternatePath = 'LDAP://substitute-your-fallback-AD-server-here';
my $strDomain = "\@substitute-your-domain-name-here";

sub authenticate {
my $strUserID       = shift || "";
my $strUserPassword = shift || "";
my $result = 0;
my $objNameSpace = Win32::OLE->GetObject ('LDAP:') or return $result;
my $objObjSec = $objNameSpace->OpenDSObject($strADsPath, $strUserID,$strUserPassword, 1);
if (Win32::OLE->LastError()==0) {
$result = 1;
}
else {
$objObjSec = $objNameSpace->OpenDSObject($strADsAlternatePath, $strUserID,$strUserPassword, 1);
if (Win32::OLE->LastError()==0) {
$result = 1;
}
}
if ($objObjSec ne undef) {
$objObjSec->Close;
}
$objNameSpace->Close;
return $result;
}

I then changed the login subroutine in TTXLogin.pm:

Code:
  my $user = TTXUser->new($query->param('login'));
  if ($user eq undef || TTXLdap::authenticate( $query->param('login'), $query->param('passwd')) ne 1) {
    $data->{ERROR_MESSAGE} = '[%Wrong User ID or Password%]';
    return undef;
  }

While my Perl experience is limited, this has been working for us for a few months now. YMMV.
Logged
Sparky
Moderator
Hero Member
*****

Karma: 82
Posts: 2,206


stop pushing all those buttons


View Profile
« Reply #2 on: October 24, 2008, 12:48:27 PM »

This is excellent.

I'm adding this to the modifications listing.
Logged

Did you update the paths in ttxcfg.cgi after moving TTX to your new location?   Undecided
To those seeking help.... please report back when you figure it out.  Cheesy
Sparky
Moderator
Hero Member
*****

Karma: 82
Posts: 2,206


stop pushing all those buttons


View Profile
« Reply #3 on: October 24, 2008, 12:49:27 PM »

moved to modifications forum.

Smiley
Logged

Did you update the paths in ttxcfg.cgi after moving TTX to your new location?   Undecided
To those seeking help.... please report back when you figure it out.  Cheesy
bbell
Newbie
*

Karma: 3
Posts: 29


View Profile
« Reply #4 on: October 24, 2008, 12:58:40 PM »

I forgot to mention in my earlier post that I still use setup.cgi to add users, setting the password field to "ignored" or some other nonsensical value.
Logged
Sparky
Moderator
Hero Member
*****

Karma: 82
Posts: 2,206


stop pushing all those buttons


View Profile
« Reply #5 on: October 24, 2008, 01:06:13 PM »

And the login name must be setup exactly the same in both TTX and Active Directory, correct?
Logged

Did you update the paths in ttxcfg.cgi after moving TTX to your new location?   Undecided
To those seeking help.... please report back when you figure it out.  Cheesy
Paul Nolette
Newbie
*

Karma: 10
Posts: 49


View Profile
« Reply #6 on: November 03, 2008, 11:09:19 AM »

This is a great Mod and works perfect! Thank you for this.
We are going to use AD authentication on some helpdesk but not on others so this is a crazy question but could you put in an if statement to use TTX login?
Basically I want to have an Admin account (not an AD account) that can login to any one of our helpdesk systems, so i need to bypass the AD auth if the username is Admin
So if the login username is Admin use ttx login routine:
Code:
  if ($user eq undef || ($user->get('passwd') eq undef) || ($user->get('passwd') ne $query->param('passwd'))) {
    $data->{ERROR_MESSAGE} = '[%Wrong User ID or Password%]';
    return undef;
}
otherwise use AD login:
Code:
  if ($user eq undef || TTXLdap::authenticate( $query->param('login'), $query->param('passwd')) ne 1) {
    $data->{ERROR_MESSAGE} = '[%Wrong User ID or Password%]';
    return undef;
}

I cannot figure out how to write the if statement for this!
Logged
Paul Nolette
Newbie
*

Karma: 10
Posts: 49


View Profile
« Reply #7 on: November 04, 2008, 03:41:52 PM »

Out of desperation I got this to work. I can't image anyone else wants to have this admin bypass but if you do here it is. Basically if a user named ttxadmin logs in it will use ttx authentication otherwise it's AD authentication.

Code:
  if ($query->param('login') eq "ttxadmin") {
    if ($user eq undef || ($user->get('passwd') eq undef) || ($user->get('passwd') ne $query->param('passwd'))) {
      $data->{ERROR_MESSAGE} = '[%Wrong User ID or Password%]';
      return undef;
    }
  } else {

    if ($user eq undef || TTXLdap::authenticate( $query->param('login'), $query->param('passwd')) ne 1) {
      $data->{ERROR_MESSAGE} = '[%Wrong User ID or Password%]';
      return undef;
    }
  }
Logged
Sparky
Moderator
Hero Member
*****

Karma: 82
Posts: 2,206


stop pushing all those buttons


View Profile
« Reply #8 on: November 04, 2008, 03:46:38 PM »

Thanks for the contribution.
Logged

Did you update the paths in ttxcfg.cgi after moving TTX to your new location?   Undecided
To those seeking help.... please report back when you figure it out.  Cheesy
chloeroxymax
Newbie
*

Karma: 1
Posts: 8


View Profile
« Reply #9 on: January 02, 2009, 09:12:20 AM »

It is worth noting that I had to add this line at the top of TTXLogin.pm to get this to work on 3.00:

use TTXLdap;

Thanks for a great mod!  We're going to put it thru its paces.
Logged
bmj
Newbie
*

Karma: 0
Posts: 10


View Profile
« Reply #10 on: May 17, 2010, 05:40:39 PM »

Also important to note that Win32::OLE is only supported by servers running Windows.   Angry

I'm working on a mod for Unix/Linux systems based on Net::LDAP bind.  Please drop me a note if anyone has experience with that lib.
« Last Edit: May 18, 2010, 06:58:15 PM by bmj » Logged
bmj
Newbie
*

Karma: 0
Posts: 10


View Profile
« Reply #11 on: May 19, 2010, 01:48:24 PM »

For AD authentication in Unix TTX implementations, replace the contents of TTXLdap.pm with the following:

Code:
package TTXLdap;

use Net::LDAP;
$TTXDropdown::VERSION='1.00';

use strict;

my $domain = "DOMAIN_GOES_HERE";
my $adserver = "AD_SERVER_IP_GOES_HERE";

sub authenticate {
  my $strUID = shift || "";
  my $strPass = shift || "";
  my $result = 0;
  my $login = $domain . "\\" . $strUID;
  my $ldap = Net::LDAP->new( "$adserver" ) or die "$@";

  my $auth = $ldap->bind ($login, password => "$strPass", version => 3);

  if ($auth->code)
  {
    # Failed, return 0
    $result = 0;
  } else {
    $result = 1;
  }

  $ldap->unbind;

  return $result;
}

1;
#

Substitute the AD server and domain as appropriate.  Note that I didn't include a fallback server (can be done pretty easily).  Also note that you still need to modify TTXLogin.pm as noted in the original post.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1 RC3 | SMF © 2001-2006, Lewis Media Valid XHTML 1.0! Valid CSS!
Page created in 0.03 seconds with 19 queries.