{"id":179,"date":"2005-12-28T15:27:25","date_gmt":"2005-12-28T21:27:25","guid":{"rendered":"http:\/\/www.brentnorris.net\/blog\/?p=179"},"modified":"2008-08-05T13:21:40","modified_gmt":"2008-08-05T20:21:40","slug":"samba-3-authenticating-to-a-windows-2003-active-directory-howto","status":"publish","type":"post","link":"https:\/\/www.brentnorris.net\/blog\/archives\/179","title":{"rendered":"SAMBA 3 Authenticating to a Windows 2003 Active Directory HOWTO"},"content":{"rendered":"<p>Finally got a good method down and it works consistantly&#8230;  You can read it in straight <a href=\"http:\/\/www.brentnorris.net\/samba2005.html\">HTML<\/a> too.<br \/>\n<!--more-->Everything done in this howto is done with root permissions.  It is always best to start out with a completely updated machine:<br \/>\n<code>yum upgrade<\/code><\/p>\n<p>Next it is important to make sure that you have the Kerberos files on your machine:<br \/>\n<code>yum install krb5-server krb5-workstation<\/code><\/p>\n<p>Next you need to edit the <code>\/etc\/krb5.conf<\/code> file so that it looks similar to this (Case IS important. Bolded Items are things that need changing) :<\/p>\n<p><code>[logging]<br \/>\ndefault = FILE:\/var\/log\/krb5libs.log<br \/>\nkdc = FILE:\/var\/log\/krb5kdc.log<br \/>\nadmin_server = FILE:\/var\/log\/kadmind.log<br \/>\n[libdefaults]<br \/>\ndefault_realm = <strong>EDMONSON.KETSDS.NET<\/strong><br \/>\ndns_lookup_realm = false<br \/>\ndns_lookup_kdc = false<br \/>\nticket_lifetime = 24h<br \/>\nforwardable = yes<br \/>\ndefault_tgs_enctypes = DES-CBC-CRC DES-CBC-MD5 RC4-HMAC<br \/>\ndefault_tkt_enctypes = DES-CBC-CRC DES-CBC-MD5 RC4-HMAC<br \/>\npreferred_enctypes = DES-CBC-CRC DES-CBC-MD5 RC4-HMAC<\/code><\/p>\n<p>[realms]<br \/>\n<strong>EDMONSON.KETSDS.NET<\/strong> = {<br \/>\nkdc = <strong>ed151000d1.edmonson.ketsds.net<\/strong><br \/>\nadmin_server = <strong><span><a href=\"http:\/\/10.76.16.50\">10.76.16.50<\/a>:749<\/span><\/strong><br \/>\ndefault_domain = <strong>edmonson.ketsds.net<\/strong><br \/>\n}<br \/>\n[domain_realm]<br \/>\n.example.com = <strong>EDMONSON.KETSDS.NET<\/strong><br \/>\nexample.com = <strong>EDMONSON.KETSDS.NET<\/strong><br \/>\n[kdc]<br \/>\nprofile = \/var\/kerberos\/krb5kdc\/kdc.conf<br \/>\n[appdefaults]<br \/>\npam = {<br \/>\ndebug = false<br \/>\nticket_lifetime = 36000<br \/>\nrenew_lifetime = 36000<br \/>\nforwardable = true<br \/>\nkrb4_convert = false<br \/>\n}<\/p>\n<p>Now it is a good idea to add your domain controller to your <code>\/etc\/hosts<\/code> file.  That way if something happens to DNS you can still resolve out to it.  We are on to editing the <code>\/etc\/samba\/smb.conf<\/code> file.  There are several things to add and change here (again case <strong>is<\/strong> important and bolded items are what needs changed or added):<br \/>\n<code>change: workgroup = <strong>EDMONSON<\/strong><br \/>\nadd: <strong>realm = EDMONSON.KETSDS.NET<\/strong><br \/>\nchange: server string = <strong>Linux Samba File Server<\/strong><br \/>\nchange: security = <strong>ADS<\/strong><br \/>\nchange: encrypt passwords = <strong>yes<\/strong><br \/>\nchange: preferred master = <strong>no<\/strong><br \/>\nadd: <strong>template shell = \/bin\/false<\/strong><br \/>\nadd: <strong>template homedir = \/home\/%D\/%U<\/strong><br \/>\nadd: <strong>idmap uid = 10000-20000<\/strong><br \/>\nadd: <strong>idmap gid = 10000-20000<\/strong><br \/>\nadd: <strong>enhanced browsing = no<\/strong><br \/>\nadd: <strong>winbind use default domain = yes<\/strong><br \/>\n<\/code><\/p>\n<p>After you get those edited then it is a good idea to run <code>testparm<\/code> and correct any errors that you get.  With just the changes that I posted above there shouldn&#8217;t be any errors.<br \/>\nNext start SAMBA and join the machine to the domain using the commands:<br \/>\n<code>\/etc\/init.d\/smb start<br \/>\nnet ads join -U bnorris@EDMONSON.KETSDS.NET<\/code><br \/>\nAgain case is important.  The program should ask you for your network password and then it should join the box to the network.<br \/>\nIf all went well you need to stop SAMBA while you finish up the pieces:<br \/>\n<code>\/etc\/init.d\/smb stop<\/code><\/p>\n<p>Now we need to edit <code>\/etc\/nsswitch.conf<\/code> and tell the machine to use Winbind to authenticate people.<br \/>\n<code>change: passwd:     files <strong>winbind<\/strong><br \/>\nchange: group:      files <strong>winbind<\/strong><\/code><\/p>\n<p>Now we can start Winbind and SAMBA back up:<br \/>\n<code>\/etc\/init.d\/winbind start<br \/>\n\/etc\/init.d\/smb start<\/code><\/p>\n<p>Test to make sure it is working using <code>wbinfo<\/code>:<br \/>\n<code>wbinfo -u<br \/>\nwbinfo -g<\/code><\/p>\n<p>Those commands should give you a list of users and groups from your domain.  If you have a particularly complex domain with lots of trusts and such to you might want to limit <code>wbinfo<\/code> to one domain with the <code>--domain=EDMONSON<\/code> option.  If <code>wbinfo<\/code> hangs and never returns then you will need to stop and start Winbind in order to get it working again.<\/p>\n<p>You can also get some info about your connection to the domain with:<br \/>\n<code>net ads info<\/code><\/p>\n<p>Now you need to enable extended Access Control Lists (ACLs) on the filesystem that you will be using.  This will give you access to extended security settings similar to Windows file permissions.  To change this we will need to edit <code>\/etc\/fstab<\/code>.  You might not want to enable ACLs for all of your filesystems as it can induce some overhead that you might not need.  Find the filesystem entry that you want to enable ACL for and edit the options field (the fourth field, usually says <code>defaults<\/code>).  After the entries that are in there put <code>,acl<\/code><\/p>\n<p>Now you need to unmount that filesystem and remount it.  The easiest way to do that is to just reboot the machine, since sometimes there might be users with files open and you can&#8217;t unmount while that is going on.<\/p>\n<p>Now if you are planning on give your users home folders you need to make their directories.  I cheated a little and did the following to quickly create mine:<br \/>\n<code>wbinfo -u --domain=EDMONSON | grep -v '$' | sort &gt; ~\/temp<br \/>\nfor i in `cat ~\/temp` ; do<br \/>\nmkdir -p \/home\/EDMONSON\/$i<br \/>\nsetfacl -m u:\"EDMONSON\\\\$i\":rwx \/home\/EDMONSON\/$i<br \/>\ndone<\/code><\/p>\n<p>That should give you a directory for every user with them having full control of that directory.  I think there is an option to SAMBA to get it to do this when a user connects to the machine, but I couldn&#8217;t find it quickly today to set it.  If anyone knows what it is, just let me know and I will edit this to get it in there.<\/p>\n<p>So there you go.  You <strong>should<\/strong> now have a machine that will authenticate to the AD and show you the shares that you are allowed to access.  If you want to add shares for specific users it isn&#8217;t too tough, just add them to <code>\/etc\/samba\/smb.conf<\/code><br \/>\nA good template share definition looks something like this:<br \/>\n<code>[vivnenoi]<br \/>\ncomment = wireless to connect field house<br \/>\npath = \/home\/shares\/vivnenoi<br \/>\nvalid users = EDMONSON\\lamar.miller EDMONSON\\jcarnes EDMONSON\\bnorris<br \/>\npublic = no<br \/>\nwritable = yes<br \/>\nprintable = no<br \/>\ncreate mask = 0765<br \/>\n<\/code><\/p>\n<p>I have also written a shell script that can be accessed through a webpage to dynamically generate shares for groups of users.  I will post in another entry soon.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Detailed HOWTO on getting a Linux machine running SAMBA 3 to use a Windows 2003 Active Directory to authenticate logins.  HOWTO was created on a Fedora Core 4 machine. <a href=\"https:\/\/www.brentnorris.net\/blog\/archives\/179\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[193,75,168,147,145],"class_list":["post-179","post","type-post","status-publish","format-standard","hentry","category-journal","tag-brent","tag-hell","tag-house","tag-ldap","tag-samba"],"_links":{"self":[{"href":"https:\/\/www.brentnorris.net\/blog\/wp-json\/wp\/v2\/posts\/179","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.brentnorris.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.brentnorris.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.brentnorris.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.brentnorris.net\/blog\/wp-json\/wp\/v2\/comments?post=179"}],"version-history":[{"count":0,"href":"https:\/\/www.brentnorris.net\/blog\/wp-json\/wp\/v2\/posts\/179\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.brentnorris.net\/blog\/wp-json\/wp\/v2\/media?parent=179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.brentnorris.net\/blog\/wp-json\/wp\/v2\/categories?post=179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.brentnorris.net\/blog\/wp-json\/wp\/v2\/tags?post=179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}