| Title: 2.2.1 - Simple search |
| NavPrev: 2.2-searching-data.html |
| NavPrevText: 2.2 - Searching Data |
| NavUp: 2.2-searching-data.html |
| NavUpText: 2.2 - Searching Data |
| NavNext: 2.2.2-more-search-options.html |
| NavNextText: 2.2.2 - More search options |
| Notice: Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance |
| with the License. You may obtain a copy of the License at |
| . |
| http://www.apache.org/licenses/LICENSE-2.0 |
| . |
| Unless required by applicable law or agreed to in writing, |
| software distributed under the License is distributed on an |
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| KIND, either express or implied. See the License for the |
| specific language governing permissions and limitations |
| under the License. |
| |
| # 2.2.1 - Simple search |
| |
| Basically, a search in **LDAP** requires a few parameters : |
| * A server on which we will send the request |
| * A port for this server |
| * A base _DN_, the location where to start the search from |
| * A filter to select the entries to be returned |
| * The user doing the search |
| * A password if the user is not already bound |
| * A scope, defining the depth we should look for |
| * The list of attributes to return |
| |
| There are several other options, which will be exposed in the next chapter. |
| |
| ## Doing a Simple Search on the command line |
| |
| Here is an exemple of search done on the base we have created : |
| |
| $ ldapsearch -h zanzibar -p 10389 -b "o=sevenSeas" -s sub "(cn=James Hook)" + |
| version: 1 |
| dn: cn=James Hook,ou=people,o=sevenSeas |
| accessControlSubentries: cn=sevenSeasAuthorizationRequirementsACISubentry,o=sevenSeas |
| creatorsName: cn=Horatio Nelson,ou=people,o=sevenSeas |
| createTimestamp: 20061203140109Z |
| |
| Here, we see that we are connecting to the **zanzibar** server, on its **10389** port. As we haven't provided any user, this is an anonymous search, which should be allowed if the server accept anonymous searches. |
| We then have the base _DN_, **"o=sevenseas"**, the filter **"(cn=James Hook)"** and the scope : **"sub"**. The last parameter, **"+"**, asks the server to return all the operational attributes. |
| |
| The result is just shown as a result of the command (here, we get back one single entry). |
| |