Re: First LDAP-Perl Script

2009-09-21 Thread Chris Ridd


On 20 Sep 2009, at 18:44, Parag Kalra wrote:

I think I got what was going wrong...If I am not wrong 'bind' method  
uses

authentication hence credentials only while making any changes
(add/modify/delete) to ldap server.

So if I will use wrong credentials to modify ldap database then it  
will

surely shout...


Not quite.

All the 'operation' methods like bind(), add(), modify(), search(),  
etc return undef if there was a problem sending the operation to the  
server. They do *not* return undef if the server fails the operation.


To check if the server fails the operation, you need to get the result  
of the operation, and test the result code inside that. This is  
commonly done like this:


---
$res = $ldap-some-operation-here(with-lots-of-arguments) or die  
Cannot send some-operation-here;


die Some operation failed (, $res-error_name, ) if $res-code;
---

This works because an LDAP OK result is numeric 0. Note operations can  
return other codes which your application might also consider to be  
OK in some sense, so you will need to modify the above logic a  
little in those cases.


Read the Net::LDAP::Message documentation to find out more things you  
can do with $res.


Cheers,

Chris


Re: First LDAP-Perl Script

2009-09-21 Thread Graham Barr


On Sep 21, 2009, at 5:41 AM, Chris Ridd wrote:



On 20 Sep 2009, at 18:44, Parag Kalra wrote:

I think I got what was going wrong...If I am not wrong 'bind'  
method uses

authentication hence credentials only while making any changes
(add/modify/delete) to ldap server.

So if I will use wrong credentials to modify ldap database then it  
will

surely shout...


Not quite.

All the 'operation' methods like bind(), add(), modify(), search(),  
etc return undef if there was a problem sending the operation to the  
server.


No, they will always return a Net::LDAP::Message object. If there is a  
local error then $res-code will be LDAP_LOCAL_ERROR


Graham.



Re: First LDAP-Perl Script

2009-09-21 Thread Chris Ridd


On 21 Sep 2009, at 13:53, Graham Barr wrote:



On Sep 21, 2009, at 5:41 AM, Chris Ridd wrote:



On 20 Sep 2009, at 18:44, Parag Kalra wrote:

I think I got what was going wrong...If I am not wrong 'bind'  
method uses

authentication hence credentials only while making any changes
(add/modify/delete) to ldap server.

So if I will use wrong credentials to modify ldap database then it  
will

surely shout...


Not quite.

All the 'operation' methods like bind(), add(), modify(), search(),  
etc return undef if there was a problem sending the operation to  
the server.


No, they will always return a Net::LDAP::Message object. If there is  
a local error then $res-code will be LDAP_LOCAL_ERROR


You're right.

Cheers,

Chris


First LDAP-Perl Script

2009-09-20 Thread Parag Kalra
Hello All

Just installed LDAP server (OpenLDAP) on Ubuntu with following base root dn
settings:
 cn=admin,dc=nodomian

Added few organisation units to it using command line utility 'ldapadd' and
few using ldap browser - 'phpldapadmin'

Then I felt like playing with Perl to connect to LDAP server and wrote
following script:

$ldap_host = localhost;
$admin = admin;
$domain = nodomain;
$dn = cn=$admin,o=$domain;
$password = mypassword;
$ldap = Net::LDAP-new($ldap_host) or die Could not establish connection to
LDAP server - $ldap_host \n;
$ldap-bind($dn,password=$password) or die Could not bind to LDAP serrver
- $ldap_host \n;

If I set wrong '$ldap_host', it shouts saying - 'could not bind to LDAP
server' and rightly so.

*However even if I set wrong '$password' or wrong '$dn' scripts still
executes successfully and doesn't shout...*

Where am I going wrong...?

Cheers,
Parag


RE: Perl Script Needed To Delete All The Files Stored In The Home Drectories.

2009-01-04 Thread Jyotishmaan Ray
Dear All,
 
I am a new bie in perl scripting language.
 
I have this problem :
 
I have around 500 students directories created on a server where they 
(students) have their own program files etc.
 
Now the priblem is to delete all these files of those students whose roll no. 
starts with
 
 s08-1-**-* 
 
where
the ** means a number between 1 and 5 (inclusive ) specifying the branch they 
study in
 the * means the a number between 0 and 100 or more
 
or 
 
can be done this way too considering the rollno as s08-1-1-**
 
where ** stands for the students regsitration number/roll number.
 
In that case the script will have to  be changed for each branch, by changing 
the number 1, 2, 3,,4 0r 5.
 
Ultimately we have to delete all the files stored in these folders without 
deleting their home directories.
 
Can any one give a nice script/ solution  to do this.
 
 

Thanks in advance, jm




  



  

Re: Perl Script Needed To Create The Home Drectories.

2008-08-20 Thread Marc Girod
Hi all,

May I add my grain of salt?

On Wed, Aug 20, 2008 at 3:20 AM, Vartak, Yash V [EMAIL PROTECTED] wrote:

 You should not expect the community to write entire stuff for you,
 the community is for programmers to help each other with genuine queries,
 and not give ready made solutions.

Granted.

 No one learns to code over night! It needs hrs of patient efforts, and you ll 
 have to work for yourself.

Sure.

 Being a new bee you should have a look at following sites they have all the 
 information you need w.r.t the project you are working

It strikes me that this reply shares with the question what I would
reproach it most: its top-down approach.

I never learned to program.
I programmed solutions to my problems at hand.
Nothing else I can really claim.

So the question 'it is not clear, provide a stepwise solution'
is non-receivable.
But, questions like 'why is there a @ on line 4?' should be
acceptable.

Marc


Re: Perl Script Needed To Create The Home Drectories.

2008-08-20 Thread Jason A. Kates
Instead of creating the home directory as part of a batch job you might
think of having the OS take care of it only when required.

Under linux you might think of updating
/etc/pam.d/system-auth and add this line:
session required  pam_mkhomedir.so skel=/etc/skel/ umask=0022

The users home directory will get created on the 1st login.
-Jason


On Tue, 2008-08-19 at 09:46 -0700, Jyotishmaan Ray wrote:
 Dear All,
 
 I am a new bie in perl. I have to create the home directories of 424 students 
 in a server machine. 
 
 The path of the home directory would be :-
 
 /mnt/btech/formatted-rollno.
 
 where formatted-rollno =s08-1-5-097
 
 
 And the input file contains all the rollnos of 424 students.
 
 
 
 A sample student file of five  students is as given below (in the format of 
 uid, MD5 password) as below:-
 
 
 
 s08-1-5-093 
 s08-1-5-094 
 s08-1-5-095   
 s08-1-5-096
 s08-1-5-097 
 
 For example, the home directories,  for the rollno, s08-1-5-097, would be 
 this-
 
 
  /mnt/btech/s08-1-5-097
 
 All the student should have read/write and execute permissions in their home 
 directories.
 
 
 Can any one provide the perl script  for doing this ?
 
 
 
 
 
   
 
 
   
-- 

Jason A. Kates ([EMAIL PROTECTED]) 
Fax:208-975-1514
Phone:  212-400-1670 x2





Re: Perl Script Needed To Create The Home Drectories.

2008-08-20 Thread Jyotishmaan Ray

 created a user by importing a ldif as shown  below:

Plz go
through this  file. However this file  is located at the LDAP server
and the homedirectories are to created in the cluster server.

dn:
uid=s08-1-5-097,ou=student,dc=nits,dc=ac,dc=in
uid: s08-1-5-097
cn:  s08-1-5-097
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword: {crypt}$1$REie6fpE$5brEKmdMZlWzxStz7Kqed.
loginShell: /bin/bash
uidNumber: 3053
gidNumber: 3053
homeDirectory: /mnt/btech/s08-1-5-097
shadowLastChange:13458
shadowMin: 0
shadowMax: 99
shadowWarning: 7




I tried excuting the script too, still the /etc/group was not updated , why ?  
The script is shown
 below:





#!/usr/local/bin/perl

use strict;
use warnings;

open(FH,/mnt/btech/rr.txt);
while(FH)
 {
   chomp($_);
   my $homedir = /mnt/btech/$_;
   `groupadd $_`;
   `mkdir $homedir; chmod 700 $homedir;` if(! -e $homedir);
}
close(FH);

what could be wrong with the script ?



While
the same script when i ran in another system where my ldap server is
running, I saw that three rollnos were added from the file-rr.txt into
the file /etc/group but again the ls-l command did nt show the changes
infact . Why??

The output of cat /etc/group command after running the script you had given:
[EMAIL PROTECTED] etc]# cat
 group
..
.
s08-1-5-095:x:500:
s08-1-5-096:x:501:
s08-1-5-097:x:502:
[EMAIL PROTECTED] etc]# 

And the output of the ls-l command is as below :-



-rw-r--r-- 1 root root   5124 2008-08-19 01:14 roll.txt
-rw-r--r-- 1 root root 37 2008-08-20 17:21 rr.txt
-rw-r--r-- 1 root root   5076 2008-08-19 20:22 r.txt
drwx-- 2 root root   4096 2008-08-20 18:44 s08-1-5-095
drwx-- 2 root root   4096 2008-08-20 18:44 s08-1-5-096
drwx-- 2 root root   4096 2008-08-20 18:44 s08-1-5-097

The output on running the script, 


Usage: groupadd [options] GROUP

Options:
  -f, --force   force exit with success status if the
 specified
    group already exists
  -r,   create system account
  -g, --gid GID use GID for the new group
  -h, --help    display this help message and exit
  -K, --key KEY=VALUE   overrides /etc/login.defs defaults
  -o, --non-unique  allow create group with
 duplicate
    (non-unique) GID

However
on my cluster server, I did get any such type of messages displyed on
running the script but at the same time ls -l command did not show up
the owner and group as the rollno, but it showed up as root a both
owner and the group.

Also the /etc/group file was not updated. why any pointers ??



No, , that the /etc/group file was not being
updated with the rollnos, from the file rr.txt, on running the script on the 
clsuter server, why what was
was wrong.

It adds to the file /ect/group but it does shows up the owner and the group as 
root only.

What is wrong ??

The output is shown below :-


drwxr-xr-x  2 s07-1-5-060 s07-1-5-060 3864 Jan 25  2008 s07-1-5-060
drwxr-xr-x  2 s07-1-5-061 s07-1-5-061 3864 Jan 25  2008 s07-1-5-061
drwxr-xr-x  2 root    root    3864 Aug 20 19:05 s08-1-5-095
drwxr-xr-x  2 root    root    3864
 Aug 20 19:05 s08-1-5-096
drwxr-xr-x  2 root    root    3864 Aug 19 23:58 s08-1-5-097
-rw-r--r--  1 root    root 239 Aug 20 19:05 s.pl

The owner and group should be the rollno. 

ANY POINTERS ??
  

--- On Wed, 8/20/08, Andrej Ricnik-Bay [EMAIL PROTECTED] wrote:
From: Andrej Ricnik-Bay [EMAIL PROTECTED]
Subject: Re: Perl Script Needed To Create The Home Drectories.
To: Marc Girod [EMAIL PROTECTED], Perl-LDAP Mailing List 
perl-ldap@perl.org
Date: Wednesday, August 20, 2008, 11:33 PM

On 20/08/2008, Marc Girod [EMAIL PROTECTED] wrote:

  But, questions like 'why is there a @ on line 4?' should be
  acceptable.
But you don't sign up for a power-sliding event and then
ask the people there what those pedals are for ... ?


  Marc
Cheers,
Andrej


-- 
Please don't top post, and don't use HTML e-Mail :}  Make your quotes
concise.

http://www.american.edu/econ/notes/htmlmail.htm



  

Re: Perl Script Needed To Create The Home Drectories.

2008-08-20 Thread Brian Reichert
On Wed, Aug 20, 2008 at 12:07:02PM -0700, Jyotishmaan Ray wrote:
 

Depending on the Linux system's policies, executing a command like this:

  useradd -m -d /mnt/btech -c $encrypted_password -s $shell $user 

will:

- create the UID in the password database
- create a group ID in /etc/groups
- add that password to the password database
- create the user's home directory
- cause said directory to be owned by that new UID and GID
- populate that directory with any template for .bashrc, etc. as
  are configured in /etc/skel

Read the manpage for the command your OS is using.  These commands
come with other arguments to manage auxiliary groups, nonstandard
home directory locations, etc.

Check for errors on each invokation; any of the above actions may
have failed for any reason.

If you want to make use of the specific UIDs and GIDs in the LDAP
data, you'll have to mess with adding groups, etc. more manually.
See groupadd(8).

If you want to preserve the password aging data, that gets more
tricky, but is still doable; see chage(1).

This is not an LDAP question.

This is not a perl question.

There are many forums that document this, and there are many
Googleable (is that a verb?) instances of 

  perl add user

out there, many using LDAP as a source of users.

There are consultants out there who'll do this work for pay, if you
feel you're in over your head.

Good luck!

-- 
Brian Reichert  [EMAIL PROTECTED]
55 Crystal Ave. #286Daytime number: (603) 434-6842
Derry NH 03038-1725 USA BSD admin/developer at large


Need Help In Writing A Perl Script.

2008-08-19 Thread Jyotishmaan Ray
Dear All,

I am a new bie in perl. I have to generate LDIF files
after reading a file containing a list of userids of a new admitted
batch of a university along with their passwords, uidNUmber And
gidNumber. Say the new batch contains 400 students, and the uidNumber
starts from the number 2631 onwards. So for each new userid read from
the file (it contains the userids and their respective MD5 password), a
new LDIF file has to be generated. The LDIF file format for a student
is :-



dn: uid=s08-1-5-097,ou=student,dc=nits,dc=ac,dc=in
uid: s08-1-5-097
cn: s08-1-5-097
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword: {crypt}$1$2P6e6UmE$ZewMWmNBQ0ghQ9l/OK0Ft/ 
loginShell: /bin/bash
uidNumber: 2631
gidNumber:
 2631
homeDirectory:
 /mnt/btech/s08-1-5-097
shadowLastChange:13458
shadowMin: 0
shadowMax: 99
shadowWarning: 7



1) 
Here the lines which should be updated are the first line, where the
uid=uid=s08-1-5-097, is to be filled up for every new uid read from the
input file.

2)

The second line is to be updated with the uid read from the input file.

3)

The third line is to be updated with the uid for value of cn:



4)

Lines 4-7 are not to be changed for anything. They would remain same as shown 
above.

5)

The line 8's userPassword has to be updated after the MD5 passoword 
corresponding to each uid.

6)

Line 6 would remain same for all the files. Nothing to be changed.

7)

uidNumber and gidNumber would be same for a stundent and should be incremented 
for the nest
 file.


8)

The home directory should be as: /mnt/btech/value of uid

where the uid's value is read from the input file, for example it is 
here-s08-1-5-097

for all the files it would be different as uid is different for each student. 
This would be their home directory.

9) The lines below the line of homedirectory  would remain same for all the 
files.

Please provide me the perl script for that. I am just a new bie and would take 
weeks to write the script for doing that.

A sample student file of five  students is as given below (in the format of 
uid, MD5 password) as below:-



s08-1-5-093 $1$2P6e6UmE$X71iU1QF6it6oxalIPqMS/    
s08-1-5-094 $1$2P6e6UmE$R37ySEfe5JPjRTmdIo2xf.    
s08-1-5-095
 $1$2P6e6UmE$VKlXe6lSoXr4aWBmuSn6u/    
s08-1-5-096    $1$2P6e6UmE$H7Q3Thg4KQKeuAvOsffp8.    
s08-1-5-097 $1$2P6e6UmE$ZewMWmNBQ0ghQ9l/OK0Ft/   


Now please generate five LDIF files in the format as shown above for each
uid after reading fro the input file of five students :-





Thanks,

Jmaan



  

RE: Need Help In Writing A Perl Script.

2008-08-19 Thread Vartak, Yash V
Hi 

What you say its should be pretty simple to do

1) First write a regex 

if input the file format is like below

uid123 , c50672216e6be50f327c7df719784fe3
uid567 , 31d3818ec221c94784c884b19d381bf3 

# below part of the code would give uid in $uid variable , $md5 would contain 
md5 hash

while()
chomp;
/(.*),(.*)/;

my $uid=$1;
my $md5=$2;

# then write print statements according to your needs eg

print dn: $uid,ou=student,dc=nits,dc=ac,dc=in\n;
print uid: $uid\n;
print cn: $uid\n;

and so on ...

then just run 

perl genLdif.pl in.txt  students.ldif

Here in.txt is the input file and student.ldif is the output file generate.

Hope this solves your problem, do let me know.

Regards,
Yash Vartak
Specialist, Distributed Systems and Services.
Neptune Orient Lines Ltd. 

Direct Tel: (+65) 6371 4483 | Direct Fax: (+65) 6371 4233 | E-mail: [EMAIL 
PROTECTED] | Website: http://www.nol.com.sg 
This message is intended for the recipient(s) named above.  It may contain 
confidential or privileged information.  If you are not the intended recipient, 
please notify the sender immediately by replying to this message and then 
delete it from your system.  Do not copy, use or circulate this communication.  
Thank you.

-Original Message-
From: Jyotishmaan Ray [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 19, 2008 5:28 PM
To: perl-ldap@perl.org
Subject: Need Help In Writing A Perl Script.

Dear All,

I am a new bie in perl. I have to generate LDIF files
after reading a file containing a list of userids of a new admitted
batch of a university along with their passwords, uidNUmber And
gidNumber. Say the new batch contains 400 students, and the uidNumber
starts from the number 2631 onwards. So for each new userid read from
the file (it contains the userids and their respective MD5 password), a
new LDIF file has to be generated. The LDIF file format for a student
is :-



dn: uid=s08-1-5-097,ou=student,dc=nits,dc=ac,dc=in
uid: s08-1-5-097
cn: s08-1-5-097
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword: {crypt}$1$2P6e6UmE$ZewMWmNBQ0ghQ9l/OK0Ft/ 
loginShell: /bin/bash
uidNumber: 2631
gidNumber:
 2631
homeDirectory:
 /mnt/btech/s08-1-5-097
shadowLastChange:13458
shadowMin: 0
shadowMax: 99
shadowWarning: 7



1) 
Here the lines which should be updated are the first line, where the
uid=uid=s08-1-5-097, is to be filled up for every new uid read from the
input file.

2)

The second line is to be updated with the uid read from the input file.

3)

The third line is to be updated with the uid for value of cn:



4)

Lines 4-7 are not to be changed for anything. They would remain same as shown 
above.

5)

The line 8's userPassword has to be updated after the MD5 passoword 
corresponding to each uid.

6)

Line 6 would remain same for all the files. Nothing to be changed.

7)

uidNumber and gidNumber would be same for a stundent and should be incremented 
for the nest
 file.


8)

The home directory should be as: /mnt/btech/value of uid

where the uid's value is read from the input file, for example it is 
here-s08-1-5-097

for all the files it would be different as uid is different for each student. 
This would be their home directory.

9) The lines below the line of homedirectory  would remain same for all the 
files.

Please provide me the perl script for that. I am just a new bie and would take 
weeks to write the script for doing that.

A sample student file of five  students is as given below (in the format of 
uid, MD5 password) as below:-



s08-1-5-093 $1$2P6e6UmE$X71iU1QF6it6oxalIPqMS/    
s08-1-5-094 $1$2P6e6UmE$R37ySEfe5JPjRTmdIo2xf.    
s08-1-5-095
 $1$2P6e6UmE$VKlXe6lSoXr4aWBmuSn6u/    
s08-1-5-096    $1$2P6e6UmE$H7Q3Thg4KQKeuAvOsffp8.    
s08-1-5-097 $1$2P6e6UmE$ZewMWmNBQ0ghQ9l/OK0Ft/   


Now please generate five LDIF files in the format as shown above for each
uid after reading fro the input file of five students :-





Thanks,

Jmaan



  


Re: Perl Script Needed To Create The Home Drectories.

2008-08-19 Thread Jyotishmaan Ray
Is that possible to create the home directories-

/mnt/btech/rollno




  

--- On Tue, 8/19/08, Jason A. Kates [EMAIL PROTECTED] wrote:




  

Re: RES: Question Regarding compiling a perl script implementing Net::LDAP

2005-04-28 Thread Graham Barr
On Thu, April 28, 2005 12:26 am, [EMAIL PROTECTED] said:
 Comment out Line 36 in Constants.pm to default to newline mode instead
 of paragraph mode... this helped me. My Perl version is 5.8.6 running
 on Whitebox/RH Linux

That line is just an optimization. But using paragraph mode does
seem to cause a few issues at time. But changing it to

  local $/= '=item';

and changing line 39 to

  next unless /^\s+(LDAP_\S+)\s+\((.*)\)/ and ($all or exists $need{$1});

should also work.

Graham.




RES: Question Regarding compiling a perl script implementing Net::LDAP

2005-03-30 Thread Ricardo Encarnação Carraretto
Hello,

Insert the following line in your Perl script (just before the use section):

#perl2exe_noopt Net::LDAP::Constant

I had the same problem and it was solved using this parameter.

Best Regards
Ricardo
 

-Mensagem original-
De: Matthews, Scott (Contr) [mailto:[EMAIL PROTECTED] 
Enviada em: segunda-feira, 28 de março de 2005 19:41
Para: [EMAIL PROTECTED]
Assunto: Question Regarding compiling a perl script implementing Net::LDAP

Hi

My apologies for bothering you.  I have created a Perl Script that reviews data 
in our LDAP directory.  It runs fine as a regular Perl Script but when I try 
and compile it to an exe using Par or even Perl2Exe I get these errors on 
execution of the resulting executeable.

LDAP_SUCCESS is not exported by the Net::LDAP::Constant module at 
Net/LDAP/Message.pm line 7
  LDAP_COMPARE_TRUE is not exported by the Net::LDAP::Constant module at 
Net/LDAP/Message.pm line 7
  LDAP_COMPARE_FALSE is not exported by the Net::LDAP::Constant module at 
Net/LDAP/Message.pm line 7
  Can't continue after import errors at Net/LDAP/Message.pm line 7
  BEGIN failed--compilation aborted at Net/LDAP/Message.pm line 7, DATA line 
20.

Compilation failed in require at Net/LDAP.pm line 13, DATA line 20.
  BEGIN failed--compilation aborted at Net/LDAP.pm line 13, DATA line 20.
  Compilation failed in require at script/modPDrive.pl line 7, DATA line 20.
  BEGIN failed--compilation aborted at script/modPDrive.pl line 7, DATA line 
20.

BEGIN failed--compilation aborted at -e line 835, DATA line 20.

I am relatively new to Perl.  I am using Activestate Perl on windows XP.  I was 
wondering if you might be able to point me in the right direction on how to get 
this to compile.  My issue is that I am the only one who has Perl installed and 
the desire of my management is to keep it that way.

I really appreciate any help you can give me and again sorry to bother you.

Thanks
  Scott Matthews




Perl Script

2004-09-21 Thread Chandrakant Bagade
Hello,
I have made on perl script(attached) which do ldapsearch.
When I run that script through perl command it works,but when I called 
it through some programme to view it in browser it never works.My OS 
Win-2000.Any Thing I am missing as some environmental variable or 
something..

Best Regards,
Chandraknt
#!/usr/local/bin/perl
# # $Header: email_imap_config.pl 30-jul-2003.18:34:00 cpolinsk Exp $
#
# email_imap_config.pl
# # Copyright (c) 2003, Oracle Corporation.  All rights reserved.  #
#NAME
#  email_imap_config.pl - one-line expansion of the name
#
#DESCRIPTION
#  Script reads email config data from oid
#
#NOTES
#  other useful comments, qualifications, etc.
#
#MODIFIED   (MM/DD/YY)
#
use strict;
require emd_common.pl;

my $OSNAME = $^O;

my $Second = ;
my $Minute = ;
my $Hour = ;
my $Day = ;
my $Month = ;
my $Year= ;
my $WeekDay = ;
my $DayOfYear = ;

($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear) = localtime(time);
my $RealMonth = $Month + 1;

if($RealMonth  10)
{
   $RealMonth = 0 . $RealMonth; # add a leading zero to one-digit months
}

if($Day  10)
{
   $Day = 0 . $Day; # add a leading zero to one-digit days
}


if($Second  10)
{
   $Second = 0 . $Second; # add a leading zero to one-digit days
}
if($Minute  10)
{
   $Minute = 0 . $Minute; # add a leading zero to one-digit days
}

if($Hour  10)
{
   $Hour = 0 . $Hour; # add a leading zero to one-digit days
}


my $Fixed_Year = $Year + 1900;

my $FormatedTime = $Fixed_Year-$RealMonth-$Day $Hour:$Minute:$Second;


my $ldap_oh=;

EMAGENT_PERL_DEBUG($ARGV[0] :: $ARGV[0]);


if(  ($OSNAME eq MSWin32) or ($OSNAME eq Windows_NT) )
{
#$ldap_oh = $ARGV[0]\\bin\\ldapsearch;
$ldap_oh = C:\\oracle_as\\bin\\ldapsearch;

}
else
{
#$ldap_oh = $ARGV[0]/bin/ldapsearch;
 $ldap_oh = C:/oracle_as/bin/ldapsearch;
}


### ldap parameters

my $ldap_host=umsvr2-sun.us.oracle.com;
my $ldap_port=3060;
my $ldap_username=cn=orcladmin;
my $ldap_password=welcome1;
my $target_type = oracle_ovf;
my $config_name = orclmailprocloglevel;
my $target =  ;
my $output=;

## Do an ldap search first looking at the target level for the data


EMAGENT_PERL_DEBUG(ldap_oh :: $ldap_oh);

$output = `$ldap_oh -h \$ldap_host\ -p $ldap_port -D \$ldap_username\ -w 
$ldap_password -b 
\cn=ovf,cn=OraVmail,cn=umdev04.us.oracle.com,cn=Computers,cn=OracleContext\ cn=ovf 
orclmailprocloglevel`;
print$output;

EMAGENT_PERL_DEBUG(output :: $output);

## Parse the result string and retrieve just the value
my $ldapValue = getLdapValue($output);
##$ldapValue=NOTIFICATION;


## Return the parsed result
print em_result=$ldapValue|$FormatedTime\n;

###
# getLdapValue
# # Takes an ldap search output string and strips the param name and '='
# from the string to retrieve only the attribute value.
###
sub getLdapValue
{
  my $attr_value = ;
  my $ldap_output = shift(@_);

  EMAGENT_PERL_DEBUG(ldap_output :: $ldap_output);

  my @lines = split(\n, $ldap_output);

  if($#lines  0)
  {
  my $attr_line = @lines[1];
  my @attr = split(=, $attr_line);
  $attr_value = @attr[1];
  }

return $attr_value;
}



RE: Perl Script

2004-09-21 Thread Paul Connolly
Your script is making a call to an external ldapsearch executable.
Therefore any problems you are having are related to your CGI
environment and not related to Net::LDAP ('cause you're not using it!)
which is what this list if for.

Paul.

-Original Message-
From: Chandrakant Bagade [mailto:[EMAIL PROTECTED] 
Sent: 21 September 2004 09:43
To: [EMAIL PROTECTED]
Subject: Perl Script

Hello,

I have made on perl script(attached) which do ldapsearch.
When I run that script through perl command it works,but when I called 
it through some programme to view it in browser it never works.My OS 
Win-2000.Any Thing I am missing as some environmental variable or 
something..

Best Regards,
Chandraknt