{"id":41,"date":"2014-10-31T16:20:37","date_gmt":"2014-10-31T08:20:37","guid":{"rendered":"http:\/\/blog.haostudio.net\/hwp\/?p=41"},"modified":"2017-07-25T00:23:47","modified_gmt":"2017-07-24T16:23:47","slug":"openindiana-ldap-server-%e5%ae%89%e8%a3%9d%e8%a8%98%e9%8c%84","status":"publish","type":"post","link":"https:\/\/blog.haostudio.net\/hwp\/openindiana-ldap-server-%e5%ae%89%e8%a3%9d%e8%a8%98%e9%8c%84\/","title":{"rendered":"OpenIndiana LDAP server \u5b89\u88dd\u8a18\u9304"},"content":{"rendered":"<!--more-->\n<h1>OpenIndiana LDAP server \u5b89\u88dd\u8a18\u9304<\/h1>\n<p>\u9996\u5148\u5148\u78ba\u5b9a\u4f60\u7684server \u662f\u5426\u80fd\u5920\u4e0a\u7db2. DNS \u662f\u5426\u6b63\u78ba. \u901a\u5e38\u525b\u88dd\u7684server \u5176DNS \u4e26\u4e0d\u6703\u88ab\u8a2d\u5b9a. DNS\u7684\u8a2d\u5b9a\u65b9\u6cd5\u5982\u4e0b<\/p>\n<pre><code>mv \/etc\/nsswitch.con \/etc\/nsswitch.conf.bak\ncp \/etc\/nsswitch.dns \/etc\/nsswitch.conf\necho &quot;nameserver 168.95.1.1&quot; &gt; \/etc\/resolv.conf\n<\/code><\/pre>\n<p>\u8a2d\u5b9a\u6b64server\u4e4bdomainname<\/p>\n<pre><code>server# domainname haostudio.net\nserver# domainname &gt; \/etc\/defaultdomain\n<\/code><\/pre>\n<p>\u67e5\u770b\u662f\u5426openldap\u7684package \u53ef\u4ee5\u5b89\u88dd<\/p>\n<pre><code>server# pkg search openldap\nINDEX           ACTION VALUE                               PACKAGE\ndescription     set    OpenLDAP Software                   pkg:\/library\/openldap@2.4.21-0.151.1.2\npkg.description set    OpenLDAP 2.4.21                     pkg:\/library\/openldap@2.4.21-0.151.1.2\npkg.summary     set    OpenLDAP Software                   pkg:\/library\/openldap@2.4.21-0.151.1.2\nbasename        dir    etc\/openldap                        pkg:\/library\/openldap@2.4.21-0.151.1.2\nbasename        dir    usr\/include\/openldap                pkg:\/library\/openldap@2.4.21-0.151.1.2\nbasename        dir    usr\/lib\/openldap                    pkg:\/library\/openldap@2.4.21-0.151.1.2\nbasename        dir    usr\/share\/doc\/openldap              pkg:\/library\/openldap@2.4.21-0.151.1.2\nbasename        dir    var\/openldap                        pkg:\/library\/openldap@2.4.21-0.151.1.2\nbasename        dir    usr\/sfw\/lib\/webmin\/caldera\/openldap pkg:\/system\/management\/webmin@1.510-0.151.1.2\nbasename        file   etc\/security\/exec_attr.d\/openldap   pkg:\/library\/openldap@2.4.21-0.151.1.2\nbasename        file   etc\/security\/prof_attr.d\/openldap   pkg:\/library\/openldap@2.4.21-0.151.1.2\nname            group  openldap                            pkg:\/library\/openldap@2.4.21-0.151.1.2\npkg.fmri        set    openindiana.org\/library\/openldap    pkg:\/library\/openldap@2.4.21-0.151.1.2\nname            user   openldap                            pkg:\/library\/openldap@2.4.21-0.151.1.2\n<\/code><\/pre>\n<p>\u5b89\u88ddOpenLDAP<\/p>\n<pre><code>server# pkg install openldap\n            Packages to install:     3\n            Create boot environment: No\n            Services to restart:     1\nDOWNLOAD                                  PKGS       FILES    XFER (MB)\nCompleted                                  3\/3     233\/233      6.3\/6.3\n\nPHASE                                        ACTIONS\nInstall Phase                                586\/586 \n\nPHASE                                          ITEMS\nPackage State Update Phase                       3\/3 \nImage State Update Phase                         2\/2 \n<\/code><\/pre>\n<p>\u70ba\u4e86\u8b93samba \u53ef\u4ee5\u4f7f\u7528LDAP server, \u6240\u4ee5\u9700\u8981\u5efa\u7acbsamba.schema, \u4e26\u4e14\u5c07\u5176\u62f7\u8c9d\u5230\/etc\/openldap\/schema\u76ee\u9304\u4e2d.\n\u81f3\u65bcsamba.schema\u4f86\u81ea\u4f55\u8655?? \u627e\u4e00\u53f0linux\u96fb\u8166, \u5b89\u88ddsamba\u5f8c, \u5230\/usr\/share\/doc\/samba-x.xx.xx \u76ee\u9304\u53bb\u6316\u5427.<\/p>\n<pre><code>server# cp samba.schema \/etc\/openldap\/schema\n<\/code><\/pre>\n<p>\u4fee\u6539 \/etc\/openldap\/sldap.conf\u5982\u4e0b<\/p>\n<pre><code># slapd.conf\n1. See slapd.conf(5) for details on configuration options.\n1. This file should NOT be world readable.\n1. include         \/etc\/openldap\/schema\/core.schema\ninclude         \/etc\/openldap\/schema\/cosine.schema\ninclude         \/etc\/openldap\/schema\/inetorgperson.schema\ninclude         \/etc\/openldap\/schema\/nis.schema\ninclude         \/etc\/openldap\/schema\/samba.schema\n\n1. Define global ACLs to disable default read access.\n\n1. Do not enable referrals until AFTER you have a working directory\n1. service AND an understanding of referrals.\n#referral       ldap:\/\/root.openldap.org\n\npidfile         \/var\/run\/openldap\/slapd.pid\nargsfile        \/var\/run\/openldap\/slapd.args\n\n1. Load dynamic backend modules:\n1. modulepath    %MODULEDIR%\n1. moduleload    back_bdb.la\n1. moduleload    back_hdb.la\n1. moduleload    back_ldap.la\n\n1. Sample security restrictions\n1.       Require integrity protection (prevent hijacking)\n1.       Require 112-bit (3DES or better) encryption for updates\n1.       Require 63-bit encryption for simple bind\n1. security ssf=1 update_ssf=112 simple_bind=64\n\n1. Sample access control policy:\n1.       Root DSE: allow anyone to read it\n1.       Subschema (sub)entry DSE: allow anyone to read it\n1.       Other DSEs:\n1.               Allow self write access\n1.               Allow authenticated users read access\n1.               Allow anonymous users to authenticate\n1.       Directives needed to implement policy:\n1. access to dn.base=&quot;&quot; by * read\n1. access to dn.base=&quot;cn=Subschema&quot; by * read\n1. access to *\n1.       by self write\n1.       by users read\n1.       by anonymous auth\n1. 1. if no access controls are present, the default policy\n1. allows anyone and everyone to read anything but restricts\n1. updates to rootdn.  (e.g., &quot;access to * by * read&quot;)\n1. 1. rootdn can always read and write EVERYTHING!\n\n#######################################################################\n1. BDB database definitions\n#######################################################################\n\ndatabase        bdb\nsuffix          &quot;dc=haostudio,dc=net&quot;\nrootdn          &quot;cn=Manager,dc=haostudio,dc=net&quot;\n1. Cleartext passwords, especially for the rootdn, should\n1. be avoid.  See slappasswd(8) and slapd.conf(5) for details.\n1. Use of strong authentication encouraged.\n#rootpw         secret\nrootpw          {SSHA}EKQY4UbJ1TLzHiNB3v+9+VgrulkqXB03\n1. The database directory MUST exist prior to running slapd AND \n1. should only be accessible by the slapd and slap tools.\n1. Mode 700 recommended.\ndirectory       \/var\/openldap\n1. Indices to maintain\nindex   objectClass     eq\n1. 1. Added by &lt;&lt;Hao&gt;&gt;\n1. index     cn,uid        eq\nindex     uidNumber     eq\nindex     gidNumber     eq\n#######################################################################\n1. Legal user can access the database, but can&#039;t access other&#039;s passowrd\n#######################################################################\n access to attrs=userPassword,shadowLastChange,sambaLMPassword,sambaNTPassword\n        by self write\n        by anonymous auth\n        by dn.base=&quot;cn=Manager,dc=haostudio,dc=net&quot; write\n        by * none\n#######################################################################\n1. For nss_ldap, must enable read for anonymous, but set the limitation for IP address\n#######################################################################\n access to *\n        by self write\n        by users read\n        by anonymous peername.IP=127.0.0.1 read\n        by anonymous peername.IP=192.168.0.0%255.255.0.0 read\n        by dn.base=&quot;cn=Manager,dc=haostudio,dc=net&quot; write\n        by * none\n\npassword-hash   {SSHA}\n<\/code><\/pre>\n<p>\u5176\u4e2drootpw \u70ba\u7ba1\u7406\u8005\u5bc6\u78bc, \u8acb\u4f7f\u7528slappasswd\u4f86\u7522\u751f<\/p>\n<pre><code>server# slappasswd\nNew password: \nRe-enter new password: \n{SSHA}EKQY4UbJ1TLzHiNB3v+9+VgrulkqXB03\n<\/code><\/pre>\n<p>\u62f7\u8c9dDB_CONFIG.example \u5230\/var\/openldap\u76ee\u9304\u4e2d<\/p>\n<pre><code>server# cp \/etc\/openldap\/DB_CONFIG.example \/var\/openldap\/DB_CONFIG\n<\/code><\/pre>\n<p>\u4fee\u6539 \/etc\/openldap\/ldap.conf\u5982\u4e0b\n#dap.conf<\/p>\n<ol>\n<li>LDAP Defaults<\/li>\n<li>\n<\/li>\n<\/ol>\n<pre><code># See ldap.conf(5) for details\n1. This file should be world readable but not world writable.\n\n#BASE   dc=example,dc=com\n#URI    ldap:\/\/ldap.example.com ldap:\/\/ldap-master.example.com:666\n\nBASE    dc=haostudio,dc=net\nURI     ldap:\/\/192.168.7.5\n\n#SIZELIMIT      12\n#TIMELIMIT      15\n#DEREF          never\n<\/code><\/pre>\n<p>\u532f\u5165ldif\u6a94<\/p>\n<pre><code>server# slapadd -f \/etc\/openldap\/slapd.conf -l xxx.ldif\n<\/code><\/pre>\n<p>!!!\u6ce8\u610f\u4e8b\u9805!!!! \u505a\u5b8c\u4e0a\u8ff0\u6b65\u9a5f\u5f8c, \u8a18\u5f97\u5230\/var\/openldap\u76ee\u9304\u4e0b, \u5c07\u6240\u6709\u6a94\u6848\u7684owner\u53cagroup\u6539\u70baopenldap.\n\u4e0d\u7136\u7684\u8a71, \u5176\u4ed6\u7684\u8edf\u9ad4\u9069\u7121\u6cd5\u900f\u904eldapadd\u4f86\u4fee\u6539\u6b04\u4f4d\u7684(\u5207\u8eab\u4e4b\u75db).<\/p>\n<pre><code>server# cd \/var\/openldap\nserver# chown openldap *\nserver# chgrp openldap *    \n<\/code><\/pre>\n<p>\u555f\u52d5LDAP server, \u5927\u529f\u544a\u6210<\/p>\n<pre><code>server# svcadm ldap\/server\n<\/code><\/pre>\n<p>#OpenIndian LDAP client \u5b89\u88dd\u65b9\u5f0f.<\/p>\n<p>\u9996\u5148\u5982\u540cserveer\u7684\u5b89\u88dd\u65b9\u5f0f\u4e00\u6a23, \u5148\u5b89\u88ddopenldap\u7684package.<\/p>\n<pre><code>server# pkg install openldap\n<\/code><\/pre>\n<p>\u7136\u5f8c\u57f7\u884c\u4e0b\u5217\u547d\u4ee4, \u8996\u60c5\u6cc1\u4fee\u6539\u4e0b\u5217\u90e8\u5206\u53c3\u6578.<\/p>\n<pre><code>server# ldapclient -v manual \\\n-a credentialLevel=anonymous \\\n-a enableShadowUpdate=false \\\n-a defaultSearchBase=ou=NIS,dc=haostudio,dc=net \\\n-a defaultServerList=192.168.9.9:389 \\\n-a serviceSearchDescriptor=passwd:ou=People,ou=NIS,dc=haostudio,dc=net \\\n-a serviceSearchDescriptor=group:ou=Group,ou=NIS,dc=haostudio,dc=net \n<\/code><\/pre>\n<p>\u7136\u5f8c\u4fee\u6539\/etc\/nsswitch.conf, \u5c07\u4e0b\u5217\u6b04\u4f4d\u7684\u503c\u4fee\u6539\u5982\u4e0b<\/p>\n<pre><code>passwd:     files ldap\ngroup:      files ldap\nnetgroup:   files ldap\n<\/code><\/pre>\n<p>\u6700\u5f8c\u555f\u52d5ldap client, \u641e\u5b9a.<\/p>\n<pre><code>server# svcadm enable network\/ldap\/client\n<\/code><\/pre>\n<hr \/>\n<h3>\u53c3\u8003\u8cc7\u6599:<\/h3>\n<ol>\n<li><a href=\"http:\/\/linadmin.wordpress.com\/2009\/11\/13\/opensolaris-ldap-client-to-linux-openldap-server\/\">OpenSolaris LDAP Client to Linux OpenLDAP Server<\/a><\/li>\n<li><a href=\"http:\/\/www.weithenn.org\/cgi-bin\/wiki.pl?OpenLDAP-%E5%8C%AF%E5%87%BA%E5%8F%8A%E5%8C%AF%E5%85%A5_LDIF_%E6%AA%94\">OpenLDAP-\u532f\u51fa\u53ca\u532f\u5165 LDIF \u6a94<\/a><\/li>\n<li><a href=\"http:\/\/wiki.rafan.org\/doc\/linuxpam\">\u751a\u9ebc\u662f Linux-PAM\uff1f<\/a><\/li>\n<li><a href=\"http:\/\/blog.xuite.net\/cheung79\/debian\/8286413\">LDAP Authentication<\/a><\/li>\n<\/ol>","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[20,17],"class_list":["post-41","post","type-post","status-publish","format-standard","hentry","category-solaris","tag-ldap","tag-solaris-2"],"_links":{"self":[{"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/posts\/41","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/comments?post=41"}],"version-history":[{"count":3,"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/posts\/41\/revisions"}],"predecessor-version":[{"id":418,"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/posts\/41\/revisions\/418"}],"wp:attachment":[{"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/media?parent=41"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/categories?post=41"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/tags?post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}