{"id":694,"date":"2012-01-24T15:25:18","date_gmt":"2012-01-24T22:25:18","guid":{"rendered":"http:\/\/jim-zimmerman.com\/?p=694"},"modified":"2012-01-24T15:25:18","modified_gmt":"2012-01-24T22:25:18","slug":"how-to-search-and-modify-an-ldap-record-from-the-command-line","status":"publish","type":"post","link":"https:\/\/jim-zimmerman.com\/?p=694","title":{"rendered":"How to search and modify an LDAP record from the command line."},"content":{"rendered":"<p>The following was verified on openldap versions 2.0 and 2.3:<\/p>\n<p>To display all attributes associated with a particular cn:<br \/>\n# ldapsearch -x -b &#8216;<em>distinguished name<\/em>&#8216; &#8216;cn=Some CN&#8217;<\/p>\n<p>Or using a wildcard:<br \/>\n# ldapsearch -x -b &#8216;<em>distinguished name<\/em>&#8216; &#8216;cn=<em>startswith<\/em>*&#8217;<\/p>\n<p>Example:<br \/>\n# ldapsearch -x -b &#8216;dc=mydomain,dc=com&#8217; &#8216;cn=myCN&#8217;<br \/>\n# ldapsearch -x -b &#8216;dc=mydomain,dc=com&#8217; &#8216;cn=myCNstartwith*&#8217;<\/p>\n<p>This information can help you to determine what you want to modify.<\/p>\n<p>How to modify an attribute value for a particular cn:<\/p>\n<p>#ldapmodify -x -D &#8216;<em>distinguished name<\/em>&#8216; -w <em>password<\/em> -f <em>filename<\/em><\/p>\n<p>Contents of <em>filename<\/em>:<\/p>\n<p>dn: <em>distinguished name<\/em><br \/>\nchangetype: modify<br \/>\nreplace: <em>attribute<\/em><br \/>\n<em>attribute<\/em>: <em>newvalue<\/em><\/p>\n<p>Example:<br \/>\n# ldapmodify -x -D &#8216;cn=admin,dc=mydomain,dc=com&#8217; -w MyPassword  -f myfile<\/p>\n<p># cat myfile<br \/>\ndn: cn=&#8221;Lastname, Firstname&#8221;, dc=mydomain, dc=com<br \/>\nchangetype: modify<br \/>\nreplace: mail<br \/>\nmail: myaccount@mydomain.com<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The following was verified on openldap versions 2.0 and 2.3: To display all attributes associated with a particular cn: # ldapsearch -x -b &#8216;distinguished name&#8216; &#8216;cn=Some CN&#8217; Or using a wildcard: # ldapsearch -x -b &#8216;distinguished name&#8216; &#8216;cn=startswith*&#8217; Example: # ldapsearch -x -b &#8216;dc=mydomain,dc=com&#8217; &#8216;cn=myCN&#8217; # ldapsearch -x -b &#8216;dc=mydomain,dc=com&#8217; &#8216;cn=myCNstartwith*&#8217; This information can help [&#038;hellip<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[245,48,246,247],"class_list":["post-694","post","type-post","status-publish","format-standard","hentry","category-documentation","tag-ldap","tag-linux","tag-modify","tag-search"],"share_on_mastodon":{"url":"","error":""},"_links":{"self":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/694","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=694"}],"version-history":[{"count":1,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/694\/revisions"}],"predecessor-version":[{"id":695,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/694\/revisions\/695"}],"wp:attachment":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=694"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=694"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}