LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 05-20-2013, 10:48 AM   #1
YankeePride13
Member
 
Registered: Aug 2012
Distribution: Ubuntu 10.04, CentOS 6.3, Windows 7
Posts: 262

Rep: Reputation: 55
LDAPS Connection to Active Directory Server for Authentication


Hello,

I want to start this off by saying I realize this may not be the best place for this type of question. I just happen to think very highly of you folks and I'd imagine at least a handful of you guys had to do this at some point so I'm looking for any guidance. I've posted my question over at technet as well to see if anyone over there can be of any assistance (I think I'll have better luck here based on past experience). Anyway...

I am currently working to set up my Ubuntu 12.04 server so that it can authenticate users off of Active Directory using nss_ldap and pam_ldap. I had no problem setting this connection up for insecure LDAP on port 389. Obviously, I want to make this connection work over LDAPS on port 636. I am, however, not having any luck setting this up. I keep getting this error when I perform an ldapsearch:

Code:
# ldapsearch -v -H ldaps://ldapserver.example.com:636 -x -D "CN=svcAcct,DC=example,DC=com" -W -b "dc=example,dc=com" -P 3 "(cn=userName)" -d 1
ldap_url_parse_ext(ldaps://ldapserver.example.com:636)
ldap_initialize( ldaps://ldapserver.example.com:636/??base )
ldap_create
ldap_url_parse_ext(ldaps://ldapserver.example.com:636/??base)
Enter LDAP Password:
ldap_sasl_bind
ldap_send_initial_request
ldap_new_connection 1 1 0
ldap_int_open_connection
ldap_connect_to_host: TCP ldapserver.example.com:636
ldap_new_socket: 3
ldap_prepare_socket: 3
ldap_connect_to_host: Trying 1.2.3.4:636
ldap_pvt_connect: fd: 3 tm: -1 async: 0
TLS: peer cert untrusted or revoked (0x42)
TLS: can't connect: (unknown error code).
ldap_err2string
ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)
Here's my ldap.conf:
Code:
base dc=example,dc=com
uri ldaps://ldapserver.example.com/
ldap_version 3
binddn CN=svcAcct,DC=example,DC=com
bindpw Password
pam_filter objectclass=posixAccount
pam_password md5
nss_map_attribute homeDirectory unixHomeDirectory
TLS_CACERT /etc/ssl/certs/joinedca.pem
The file /etc/ssl/certs/joinedca.pem contains cacert.pem as well as the certs I grabbed via these instructions:

http://blogs.msdn.com/b/alextch/arch...directory.aspx

In order to try and test the certs, I decided to write up a quick PERL script to see if I can connect:

Code:
#!/usr/bin/perl -w
use strict;
use warnings;
use Net::LDAPS;
use Data::Dumper;

my $targetHost = 'ldapserver.example.com';
my $targetAccountDN = "CN=svcAcct,DC=example,DC=com";
my $targetAccountPassword = 'Password';
print "Connecting and Binding to $targetHost...";
my $targetLdap = Net::LDAPS->new($targetHost, port => '636', verify => 'require', cafile => '/etc/ssl/certs/joinedca.pem') or die "targetLdap error : [$@]";
my $msg = $targetLdap->bind($targetAccountDN, password => $targetAccountPassword, version => 3);
$msg = $targetLdap->search(
        base   => 'DC=example,DC=com',
        filter => "(&(objectClass=OrganizationalPerson)(cn=userName))"
);
And that works without a problem. It binds, and searches for userName without a hitch. Anyone have any ideas as to what I'm messing up here? Let me know if more info is needed. Thanks!
 
Old 05-20-2013, 01:05 PM   #2
grim76
Member
 
Registered: Jun 2007
Distribution: Debian, SLES, Ubuntu
Posts: 308

Rep: Reputation: 50
You will have to configure LDAPS on the AD side. It is not configured by default and you will have to put into place an SSL cert that both sides can trust. More than likely the issues is one side or the other trusting the certificate.
 
Old 05-20-2013, 02:23 PM   #3
YankeePride13
Member
 
Registered: Aug 2012
Distribution: Ubuntu 10.04, CentOS 6.3, Windows 7
Posts: 262

Original Poster
Rep: Reputation: 55
@grim76

I'd totally be on the same page as you if the PERL script didn't work. But it does...so that leads me to believe there is some misconfiguration on the Ubuntu side.
 
Old 05-20-2013, 02:31 PM   #4
grim76
Member
 
Registered: Jun 2007
Distribution: Debian, SLES, Ubuntu
Posts: 308

Rep: Reputation: 50
You were pointed directly at the ca file in /etc/ssl/certs. That is probably why it worked. I know in Debian I have to rebuild that location when I add a new internal cert authority for the system to trust the cert out of the gate.
 
Old 05-21-2013, 08:28 AM   #5
YankeePride13
Member
 
Registered: Aug 2012
Distribution: Ubuntu 10.04, CentOS 6.3, Windows 7
Posts: 262

Original Poster
Rep: Reputation: 55
@grim76

in my ldap.conf file I have this line:

Code:
TLS_CACERT /etc/ssl/certs/joinedca.pem
That's pointing to the same file. Unless I have the wrong attribute? Also, could you elaborate what you mean by "I know in Debian I have to rebuild that location when I add a new internal cert authority for the system to trust the cert out of the gate." ? Not sure how I would go about doing this.

Thanks for your help!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux server authentication with Active Directory capricorn80 Linux - Server 5 05-29-2010 03:40 PM
HOW TO: SUSE Linux Enterprise Desktop SLED10 LDAP / Kerberos Authentication to Active Directory / Windows Server 2003 R2 Shannon_VanWagner LinuxAnswers Discussion 2 06-13-2007 09:29 AM
HOW TO: SUSE Linux Enterprise Desktop SLED10 LDAP / Kerberos Authentication to Active Directory / Windows Server 2003 R2 Shannon_VanWagner LinuxAnswers Discussion 0 03-23-2007 02:22 PM
Active Directory Authentication for FTP server element247 Linux - Server 3 03-23-2007 01:34 PM
How to setup linux file server that integrates with Active Directory Authentication? redkintanar Linux - General 1 11-16-2006 07:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 02:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration