]> git.sur5r.net Git - openldap/blob - clients/ud/help.c
Don't depend error handling on exact resultCode.
[openldap] / clients / ud / help.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6 /*
7  * Copyright (c) 1992, 1993  Regents of the University of Michigan.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms are permitted
11  * provided that this notice is preserved and that due credit is given
12  * to the University of Michigan at Ann Arbor. The name of the University
13  * may not be used to endorse or promote products derived from this
14  * software without specific prior written permission. This software
15  * is provided ``as is'' without express or implied warranty.
16  */
17
18 #include "portable.h"
19
20 #include <stdio.h>
21
22 #include <ac/ctype.h>
23 #include <ac/string.h>
24 #include <ac/time.h>
25
26 #include <lber.h>
27 #include <ldap.h>
28
29 #include "ud.h"
30
31
32 void
33 print_help( char *s )
34 {
35         int len;                        /* command length */
36
37 #ifdef DEBUG
38         if (debug & D_TRACE)
39                 printf("->print_help(%s)\n", s);
40 #endif
41         if (s == NULL)
42                 len = 0;
43         else {
44                 len = strlen(s);
45                 if (!strcasecmp(s, "commands"))
46                         len = 0;
47         }
48
49         /* print general help, or just on topic 's' if provided */
50         if (len == 0) {
51                 printf("\n  Here are brief descriptions of available commands:\n\n");
52                 printf("  ?                    To print this list.\n");
53                 printf("  bind [who]           To bind (authenticate) to the directory.\n");
54                 printf("  cb [where]           To change the search base.\n");
55                 printf("  change [entry]       To change information associated with an entry.\n");
56                 printf("  create [group]       To create a new group entry.\n");
57                 printf("  dereference          To toggle dereferencing of aliases.\n");
58 #ifdef UOFM
59                 if (isatty( 1 )) {
60 #endif
61                         printf("  vedit [entry]        To edit a complete Directory entry using your editor.\n");
62 #ifdef UOFM
63                 }
64 #endif
65                 printf("  find [entry]         To find an entry in the directory.\n");
66
67                 printf("  groupbase [where]    To change the group base.\n");
68                 printf("  help [command]       To display detailed help for a particular command.\n");
69                 printf("  join [group]         To subscribe to a group.\n");
70                 printf("  list [who]           To list the groups owned by someone.\n");
71                 printf("  memberships [who]    To list out the groups in which someone is a member.\n");
72                 printf("  purge [group]        To remove obsolete entries from a group.\n");
73                 printf("  quit                 To terminate the program.\n");
74                 printf("  remove [group]       To remove a group entry.\n");
75                 printf("  resign [group]       To unsubscribe from a group.\n");
76                 printf("  status               To display directory connection status.\n");
77                 printf("  tidy                 To unsubscribe from groups that no longer exist.\n");
78                 printf("  verbose              To toggle the verbose switch.\n");
79
80                 printf("\n  Type \"help <command-name>\" to get help about a particular command.");
81                 printf("\n  Type \"help options\" to get help about options in brackets above.\n");
82 #ifdef UOFM
83                 printf("\n  Bugs in ud should be reported via e-mail to:  OpenLDAP-its@OpenLDAP.org\n" );
84                 printf("\n  For more assistance with ud, contact the ITD Consultants by phoning\n" );
85                 printf("      764-HELP or by sending e-mail to:  consulting.help@umich.edu\n" );
86 #endif /* UOFM */
87         }
88         else if (!strncasecmp("options", s, len)) {
89                 printf("\n");
90                 format("Most commands need additional information in order to work.  For example, the 'remove' command needs to know the name of the group to remove.  This can be specified along with the 'remove' command, or the program will prompt you for the information.", 75, 2);
91                 printf("\n");
92                 printf("  [entry]      An entry needs to be specified.  This may be a person or a\n");
93                 format("group.  The name can be specified as either a ordinary name (e.g., 'Jane Doe'), or as some other identifying characteristic (e.g., 'uid=babs').", 75, 15);
94                 printf("\n");
95                 printf("  [group]      A group in the Directory needs to be specified.  This name\n");
96                 format("should be specified as a ordinary name (e.g., 'Friends of maX500').", 75, 15);
97                 printf("\n");
98                 printf("  [where]      A place in the Directory needs to be specified.  This name\n");
99                 format("should be specified as an LDAP-style name (e.g., 'ou=people, o=University of Michigan, c=United States of America').  In most cases, it is easier to omit the [where] and allow the program to guide you.", 75, 15);
100                 printf("\n");
101                 printf("  [who]        A person in the Directory needs to be specified.  This name\n");
102                 format("can be specified as either a ordinary name (e.g., 'Jane Doe'), or as some other identifying characteristic (e.g., 'uid=babs').", 75, 15);
103         }
104         else if (!strncasecmp("list", s, len)) {
105                 printf("  list [who]\n\n");
106                 format("Prints out the list of groups owned by the person specified.", 75, 2);
107         }
108         else if (!strncasecmp("memberships", s, len)) {
109                 printf("  memberships [who]\n\n");
110                 format("Prints out the list of groups in which the person specified is a member.", 75, 2);
111         }
112         else if (!strncasecmp("vedit", s, len)) {
113                 printf("  vedit [entry]\n\n");
114                 format("Looks up the specified person in the Directory, and then writes this entry into a file.  It then uses the EDITOR environment variable to select an editor, and then loads this file into the editor.  The entry can now be modified in any way desired, and when the editor is exited, the entry will be written back into the Directory.", 75, 2);
115         }
116         else if (!strncasecmp("status", s, len)) {
117                 printf("  status\n\n");
118                 format("Prints out the current connection status.  Lists the name of the current LDAP server, the current search base, the current group base, and the identity to which you are bound.  If you have not bound as anyone then ud considers you bound as Nobody.  cd is an alias for cb.", 75, 2);
119         }
120         else if (!strncasecmp("groupbase", s, len)) {
121                 printf("  groupbase [where]\n\n");
122                 format("The syntax and use of this command is identical to the more commonly used 'cb' command.  This command sets the base which is used to create groups in the LDAP Directory.  Setting the base to a certain value does not necessarily grant the person write-access to that part of the Directory in order to successfully create a group.", 75, 2);
123         }
124         else if (!strncasecmp("cd", s, len) || !strncasecmp("cb", s,len)) {
125                 printf("  cb [where]\n");
126                 printf("  cd [where]\n\n");
127                 format("The cb command changes the search base.  By default, this program looks only in the local part of the Directory.  By using the cb command, you can search other parts of the Directory.", 75, 2);
128         printf("\n  Examples:\n");
129         printf("\n            * cb ..\n\n");
130         format("changes the search base so that it is one level higher in the Directory.  Note that if you perform several of these in a row you will move to the root of the Directory tree.", 75, 2);
131         printf("\n            * cb ?\n\n");
132         format("prints out a list of the possible areas to search below the current search base.  This is useful once you have moved high in the tree and wish to snoop about.", 75, 2);
133         printf("\n            * cb default\n\n");
134         format("sets the search base to its original default value.", 75, 2);
135         printf("\n            * cb o=Merit Computer Network, c=US\n\n");
136         format("sets the search base to organization given, the Merit Computer Network in this case.  This comamnd checks the validity of the specified search base, and rejects it if it is not a valid Distinguished Name (DN).  A DN uniquely identifies a portion of the global LDAP namespace.", 75, 2);
137         }
138         else if (!strncasecmp("quit", s, len) || !strncasecmp("stop",s, len)) {
139                 printf("  quit\n");
140                 printf("  stop\n\n");
141                 printf("  Quits the program.  'stop' is an alias for 'quit'.\n");
142         }
143         else if (!strncasecmp("find", s, len) || !strncasecmp("display", s, len) || !strncasecmp("show", s, len)) {
144                 printf("  find [entry]\n");
145                 printf("  show [entry]\n");
146                 printf("  display [entry]\n\n");
147                 format("Displays information about the person specified.  If the name specified matches more than one person, one will be presented a list from which to make a choice.  'show' and 'display' are aliases for 'find.'", 75, 2);
148         }
149         else if (!strncasecmp("bind", s, len)) {
150                 printf("  bind [who]\n\n");
151                 format("Binds (authenticates) to the Directory.  It is generally necessary to bind to the Directory in order to look at privileged entries or to modify an entry.   Allows one to authenticate prior to issuing a 'change' or 'modify' command.  Most often used by administrators to bind to an identity.", 75, 2);
152         }
153         else if (!strncasecmp("modify", s, len) || !strncasecmp("change", s, len)) {
154                 printf("  modify [entry]\n");
155                 printf("  change [entry]\n\n");
156                 format("Changes information associated with an entry in the LDAP Directory.  'change' is an alias for 'modify'.", 75, 2);
157         }
158         else if (!strncasecmp("verbose", s, len)) {
159                 printf("  verbose\n\n");
160                 format("Turns on long and windy messages which might be useful to new users of this program.  If verbose mode is already on, this turns it off.", 75, 2);
161         }
162         else if (!strncasecmp("dereference", s, len)) {
163                 printf("  dereference\n\n");
164                 format("Turns off following of aliases when searching, etc.  If alias dereferencing has already been turned off, this turns it back on.", 75, 2);
165         }
166         else if (!strncasecmp("create", s, len)) {
167                 printf("  create [group]\n\n");
168                 format("Creates a new group in the Directory.", 75, 2);
169         }
170         else if (!strncasecmp("join", s, len) || !strncasecmp("subscribe", s, len)) {
171                 printf("  join [group]\n");
172                 printf("  subscribe [group]\n\n");
173                 format("Adds the person as a subscriber to the specified group.", 75, 2);
174         }
175         else if (!strncasecmp("purge", s, len)) {
176                 printf("  purge [group]\n\n");
177                 format("Goes through the specified group looking for Distinguished Names that cannot be found.  As it finds each one, it gives the person an opportunity to delete it.", 75, 2);
178         }
179         else if (!strncasecmp("resign", s, len) || !strncasecmp("unsubscribe", s, len)) {
180                 printf("  resign [group]\n");
181                 printf("  unsubscribe [group]\n\n");
182                 format("Deletes the person from the specified group.", 75, 2);
183         }
184         else if (!strncasecmp("remove", s, len)) {
185                 printf("  remove [group]\n\n");
186                 format("Removes a group from the Directory.", 75, 2);
187         }
188         else if (!strncasecmp("help", s, len)) {
189                 format("Prints out a brief description of each command.", 75, 2);
190         }
191         else if (!strncasecmp("tidy", s, len)) {
192                 printf("  tidy\n\n");
193                 format("Unsubscribes you from non-existent groups.  Useful when you cannot resign from a group because, while your LDAP entry still contains a pointer to it, someone has removed a group of which you were a subscriber.", 75, 2);
194         }
195         else if (*s == '?') {
196                 format("Prints out a brief description of each command.  Same as typing 'help help'.", 75, 2);
197         }
198         else {
199                 printf("  Don't recognize <%s>\n", s);
200         }
201 }