gdipuserget.pl 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/usr/bin/perl
  2. #####################################################
  3. # gdipuserget.pl
  4. #
  5. # This script dumps the data for a user in the GnuDIP
  6. # database.
  7. #
  8. # Return codes:
  9. # 0 - success
  10. # 1 - user does not exist
  11. # 2 - configuration problem
  12. #
  13. # See COPYING for licensing information.
  14. #
  15. #####################################################
  16. # PERL modules
  17. use strict;
  18. use Getopt::Std;
  19. # global variables
  20. use vars qw($conf $gnudipdir);
  21. # locate ourselves
  22. use FindBin;
  23. BEGIN {
  24. $gnudipdir = '';
  25. if ($FindBin::Bin =~ /(.*)\/.+?/) {
  26. $gnudipdir = $1;
  27. }
  28. }
  29. use lib "$gnudipdir/lib";
  30. # GnuDIP common subroutines
  31. use gdipmaint;
  32. use gdiplinemode;
  33. # process command line
  34. sub usage {
  35. print STDERR <<"EOQ";
  36. usage: gdipuserget.pl { -h | user domain }
  37. usage: Display GnuDIP user \"user\" within domain \"domain\".
  38. usage: -h: Print this usage message.
  39. EOQ
  40. }
  41. use vars qw/ $opt_h /;
  42. if (!getopts('h')) {
  43. usage();
  44. exit 2;
  45. }
  46. if ($opt_h) {
  47. usage();
  48. exit;
  49. }
  50. if (@ARGV ne 2) {
  51. usage();
  52. exit 2;
  53. }
  54. # hash reference for gdipmaint routine
  55. my %mainthash;
  56. my $maintinfo = \%mainthash;
  57. $$maintinfo{'username'} = $ARGV[0];
  58. $$maintinfo{'domain'} = $ARGV[1];
  59. # get preferences from config file
  60. $conf = getconf();
  61. # do it
  62. my $response = '';
  63. my $retcode = maintget($maintinfo, \$response);
  64. print STDOUT $response;
  65. exit $retcode;