Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Does any one know how to call LDAP from UNIX script ?

Re: Does any one know how to call LDAP from UNIX script ?

From: Suzy Vordos <lvordos_at_qwest.com>
Date: Thu, 02 May 2002 14:58:48 -0800
Message-ID: <F001.00456F84.20020502145848@fatcity.com>

Here are a few more resources:

http://www.umich.edu/~dirsvcs/ldap/ldclients.html (you could download the client for Unix and use those libraries in shell)

http://www.mozilla.org/directory/standards.html

Suzy Vordos wrote:
>
> Yes, you'd need the LDAP API libraries, check here
> http://www.openldap.org/
>
> Steven Joshua wrote:
> >
> > Thanks for the code.
> > But can we do this in UNIX shell script or Java?
> >
> > Thanks again
> >
> > Steven
> >
> > --- Charlie Mengler <charliem_at_mwh.com> wrote:
> > > I hope you can read UGLY Perl code.
> > >
> > > HTH & YMMV!
> > >
> > > #!/usr/local/bin/perl
> > > # File: chg-oracle-passwd.cgi
> > > use Net::LDAP;
> > > use Carp;
> > > use DBI;
> > > $ENV{"ORACLE_HOME"} =
> > > "/db02/app/oracle/product/8.1.6";
> > > print "Content-type: text/html\n\n";
> > > print "<HTML>\n\n<BODY>\n\n";
> > > #print "METHOD = $ENV{'REQUEST_METHOD'}\n";
> > > if ($ENV{'REQUEST_METHOD'} eq 'GET') {
> > > $form_info = $ENV{'QUERY_STRING'};
> > > }
> > > elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
> > > $form_info = '';
> > > $bytes = $ENV{'CONTENT_LENGTH'};
> > > read (STDIN, $form_info, $bytes);
> > > }
> > > @pairs = split(/&/, $form_info);
> > > foreach $pair (@pairs) {
> > > ($name, $value) = split(/=/, $pair);
> > > $value =~ tr/+/ /;
> > > $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",
> > > hex($1))/eg;
> > > if ($name eq "UNAME") {
> > > $istring = $value;
> > > }
> > > if ($name eq "PWORD") {
> > > $passwd = $value;
> > > }
> > > if ($name eq "DATABASE") {
> > > $dbase = $value;
> > > }
> > > }
> > > #
> > > my ($ldap, $res, $code);
> > > $mypasswd = $passwd;
> > > $myuid = $istring;
> > > $ldap = Net::LDAP->new('ldap.mwh.com:389') || die
> > > "$@";
> > > $mesg = $ldap->bind('cn=Directory Manager') ||
> > > die("failed to bind with ",
> > > $mesg->code(),"\n");
> > > $res = $ldap->search
> > > (
> > > base => "ou=People,o=mwh.com",
> > > filter => "&(uid=$myuid )
> > > (!(objectclass=alias))",
> > > attrs => []
> > > ) || die;
> > > $code = $res->code;
> > > $cnt = $res->count;
> > > #print "After 1st LDAP call using $myuid with
> > > results = $code<br>\n";
> > > #die "User $myuid not found" if $code || $res->count
> > > != 1;
> > > if ( $code == 1 || $cnt == 1 )
> > > {
> > > $valid_username = 1;
> > > #print "code equal to $code and count = $cnt
> > > <br>\n";
> > > my $entry = $res->entry(0);
> > > $res = $ldap->bind(dn => $entry->dn, password =>
> > > $mypasswd) or die;
> > > $code = $res->code;
> > > #print "LDAP return value = $code \n";
> > > #die "Login failed" if $code;
> > > if ( $code != 0 )
> > > {
> > > $pwmatch = 0;
> > > } else
> > > {
> > > $pwmatch = 1;
> > > }
> > > #$mesg = $ldap->search
> > > #print "mesg is $mesg <br>";
> > > } else
> > > {
> > > $valid_username = 0;
> > > $pwmatch = 0;
> > > #print "invalid username <br>";
> > > }
> > > $ldap->unbind;
> > >
> > > Steven Joshua wrote:
> > > >
> > > > Hello:
> > > >
> > > > Hope the subject make sense. I'm new to LDAP, and
> > > > don't know how it works.
> > > > I need to use SQL Loader to load a text file into
> > > > Oracle817 Database from a unix box. The file/data
> > > > comes from LDAP server. My question is: how do I
> > > get
> > > > the file/object from LDAP site from my unix
> > > script?
> > > >
> > > > Does anyone has any examples? or know a helpful
> > > URL?
> > > >
> > > > Thanks
> > > >
> > > > From Steven
> > > >
> > > > __________________________________________________
> > > > Do You Yahoo!?
> > > > Yahoo! Health - your guide to health and wellness
> > > > http://health.yahoo.com
> > > > --
> > > > Please see the official ORACLE-L FAQ:
> > > http://www.orafaq.com
> > > > --
> > > > Author: Steven Joshua
> > > > INET: wndyu_at_yahoo.com
> > > >
> > > > Fat City Network Services -- (858) 538-5051
> > > FAX: (858) 538-5051
> > > > San Diego, California -- Public Internet
> > > access / Mailing Lists
> > > >
> > >
> > --------------------------------------------------------------------
> > > > To REMOVE yourself from this mailing list, send an
> > > E-Mail message
> > > > to: ListGuru_at_fatcity.com (note EXACT spelling of
> > > 'ListGuru') and in
> > > > the message BODY, include a line containing: UNSUB
> > > ORACLE-L
> > > > (or the name of mailing list you want to be
> > > removed from). You may
> > > > also send the HELP command for other information
> > > (like subscribing).
> > >
> > > --
> > > Charlie Mengler
> > > Maintenance Warehouse
> > > charliem_at_mwh.com 10641
> > > Scripps Summit Ct.
> > > 858-831-2229 San Diego,
> > > CA 92131
> > > Am I sure? Of course I'm sure. I could be wrong, but
> > > I'm sure for now!
> > > --
> > > Please see the official ORACLE-L FAQ:
> > > http://www.orafaq.com
> > > --
> > > Author: Charlie Mengler
> > > INET: charliem_at_mwh.com
> > >
> > > Fat City Network Services -- (858) 538-5051 FAX:
> > > (858) 538-5051
> > > San Diego, California -- Public Internet
> > > access / Mailing Lists
> > >
> > --------------------------------------------------------------------
> > > To REMOVE yourself from this mailing list, send an
> > > E-Mail message
> > > to: ListGuru_at_fatcity.com (note EXACT spelling of
> > > 'ListGuru') and in
> > > the message BODY, include a line containing: UNSUB
> > > ORACLE-L
> > > (or the name of mailing list you want to be removed
> > > from). You may
> > > also send the HELP command for other information
> > > (like subscribing).
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Yahoo! Health - your guide to health and wellness
> > http://health.yahoo.com
> > --
> > Please see the official ORACLE-L FAQ: http://www.orafaq.com
> > --
> > Author: Steven Joshua
> > INET: wndyu_at_yahoo.com
> >
> > Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
> > San Diego, California -- Public Internet access / Mailing Lists
> > --------------------------------------------------------------------
> > To REMOVE yourself from this mailing list, send an E-Mail message
> > to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> > the message BODY, include a line containing: UNSUB ORACLE-L
> > (or the name of mailing list you want to be removed from). You may
> > also send the HELP command for other information (like subscribing).
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author: Suzy Vordos
> INET: lvordos_at_qwest.com
>
> Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
> San Diego, California -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from). You may
> also send the HELP command for other information (like subscribing).

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Suzy Vordos
  INET: lvordos_at_qwest.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Thu May 02 2002 - 17:58:48 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US