Link to home
Start Free TrialLog in
Avatar of KNVB HK
KNVB HKFlag for Hong Kong

asked on

How to connect the directory service of exchange server?

How to connect the directory service of exchange server?

I am using Windows NT 4.0 server , iPlanet Enterprise server 4.1 Web Server and Active Perl 5.6

I have tried to install the Perl-LDAP  modules.
However, there are a synate error in the modules, that mean it cannot work.

Thus, is there any other method to do it.
I just need to the use email address to search alias from the exchange server.
Avatar of ahoffmann
ahoffmann
Flag of Germany image

does the Exchange Server listen on port 389?
Could you please post the erros.
Avatar of KNVB HK

ASKER

Yes, I can use the outlook express to connect to it.
The error message is something like "Compilation error in XXX.pm"
> Yes, I can use the outlook express to connect to it.
Are you shure that Outllok uses the LDAP port to connect, I won't believe.

> .. something like Compilation error"
well is it red or green @~(

Would you please post exact messages, if you realy expect help.
perl is very noisy about error messages: module name, line#, and other details.
Avatar of KNVB HK

ASKER

>Are you shure that Outllok uses the LDAP port to connect, I won't believe.

Yes, I check it in the properties page. It use 389 port.Also, I am using "outlook express" not outlook.

About the error message, I will give you when I back to the office.(today is sunday).
Avatar of KNVB HK

ASKER

Sorry to bother you, the error message is that:
Can't locate Convert/ASN1.pm in @INC (@INC contains: C:/Perl/lib C:/Perl/site/li
b .) at C:/Perl/site/lib/Net/LDAP.pm line 11.
BEGIN failed--compilation aborted at C:/Perl/site/lib/Net/LDAP.pm line 11.
Compilation failed in require at E:\html\cgi-bin\LDAP.pl line 1.
BEGIN failed--compilation aborted at E:\html\cgi-bin\LDAP.pl line 1.
Avatar of KNVB HK

ASKER

I have install the convert-asn1 module.
However, it return nothing.
you euther need to install the module in one of the paths known by @INC, or you need to extend @INC with the path where you installed the module.
   push( @INC, '/your/path/to/module' );
Avatar of KNVB HK

ASKER

After install the asn1 modules, the error message is disappear. Also, I can platform search. However, I still cannot get any result from the exchange server. I think it may be the convention problem
again, posting more information (part of script, error messages, etc.) might help ;-)
Avatar of KNVB HK

ASKER

In fact, there are no error message return.
It just return nothing.
#!c:\perl\bin\perl
print "Content-type: text/html\n\n";
use Net::LDAP qw(:all);                      # use for all code

$ldap = Net::LDAP->new('myserver',async => 1) or die "$@";
#$mesg = $ldap->bind( version => 3 );         # use for searches
$ldap->bind ;
$mesg = $ldap->search (  # perform a search
                        base   => "c=US,o=CLK",
                        filter => "(&(cn=c s tsang))"
                       );
 
#$mesg->code && die $mesg->error;
$i=0;
print "Hello<br>";print ++$i;
foreach $entry ($mesg->all_entries)
  {    
       $entry->dump;
  }
$ldap->unbind;   # take down session
- does the script work from commandline, not within your webserver?
- what does
       $mesg->code && die $mesg->error;
  tell you (commented out above)
- I'm not shure if
        filter => "(&(cn=c s tsang))"
  works 'cause of the blanks, probably try
         filter => "(&(cn=*tsang))"
  or escape the blanks
Avatar of KNVB HK

ASKER

I have followed your instruction to adjust my program.
However, it still return nothing.

Here is my code:
#!c:\perl\bin\perl
print "Content-type: text/html\n\n";
use Net::LDAP qw(:all);                      # use for all code

$ldap = Net::LDAP->new('AAHOES',async => 1) or die "$@";
#$mesg = $ldap->bind( version => 3 );         # use for searches
$ldap->bind ;
$mesg = $ldap->search (  # perform a search
                        base   => "c=US,o=HKAIRPORT,ou=CLK,cn=Recipients",
                        filter => "(&(cn=*tsang))"
                       );
 
#$mesg->code && die $mesg->error;
$i=0;
print "Hello<br>";
##print ++$i;
foreach $entry ($mesg->all_entries)
  {    
       $entry->dump;
  }
$ldap->unbind;   # take down session
> I have followed your instruction to adjust my program.
and what was the output of   $mesg->code and $mesg->error ?
 
Avatar of KNVB HK

ASKER

It return :
DSA is unwilling to perform at my_file_name line 13
is this all what you get from Active Perl? useless!
line 13 is a comment.
If you count only perl statements, it's the $entry->dump;  which makes sence according to the message.
That's 'cause you do a anonimous bind, probably.
Avatar of KNVB HK

ASKER

If I comment line 13, nothing return.
If I uncomment line 13 ,return the previous error.
what exactly is "line 13"?
A real perl interpreter list the cpmplete line.
Could you please be more specific.
Avatar of KNVB HK

ASKER

Line 13 content is:
$mesg->code && die $mesg->error;
that could not be, 'cause this line is commented out (in what you posted here) !
Avatar of KNVB HK

ASKER

I have another coding which return error message="SET decode not implemented".
Here is the code:
use strict;
use Net::LDAP;

my $ldap_server = "server_name";
my $BASEDN = "o=HKAIRPORT, c=*";

my @fields = qw(cn mail sn givenname);

my $ldap = Net::LDAP->new($ldap_server) or die "$@";

$ldap->bind;

my @result;

foreach my $ask_for (@ARGV) {
    my $query = join '', map { "($_=$ask_for*) " } @fields;
    my $mesg = $ldap->search(base => $BASEDN, filter => "(|$query)");
    $mesg->code && die $mesg->error;
    foreach my $entry ($mesg->all_entries) {
        my $mail = $entry->get_value('mail');
        my $name = $entry->get_value('givenName') . " " . $entry->get_value('sn');
        my $telephone = $entry->get_value('telephoneNumber');
        push(@result, "$mail\t$name\t$telephone");
    }
}
print "LDAP query: found ", scalar(@result), "\n";
print join "\n", @result;

exit 1 if ! @result;

$ldap->unbind;
Avatar of KNVB HK

ASKER

The file name of about the file is ldap.pl.
If I execute the file in command line using "ldap sn=c s", it return "Admin Limit exceeded at line 18".
Here is the content of line 18:

$mesg->code && die $mesg->error;


which problem should be solved?
Avatar of KNVB HK

ASKER

I just want to know the meaning of "Admin Limit exceeded".
Avatar of KNVB HK

ASKER

This is another piece of code:
use Net::LDAP;
$server='my_exchange_server';
$ldap = Net::LDAP->new($server) or die "$@";
$ldap->bind('cn=my_nt_username,cn=my_org', password=>'my_nt_password');
$mesg = $ldap->search(
                       base   => "cn=Recipients,ou=my_site,o=my_org",
                       filter => "cn=my_alias_in_exchange_ server",
                      );

  $mesg->code && die $mesg->error;
  print $mesg->code."\n";
  my $max = $mesg->count;
  print $max;
  for( my $index = 0 ; $index < $max ; $index++)
  {
    my $entry = $mesg->entry($index);
    foreach my $attr ($entry->attributes)
      {
        foreach my $value ($entry->get_value($attr))
          {
            print $attr, ": ", $value, "\n";
          }
      }
  }
undef $ldap;

It return 0(no error) and 0 (0 entry found)
However, if I change "cn=my_alias_in_exchange_ server" to "rdn=my_alias_in_exchange_ server", it return "SET decode not implemented"
hmm, I'm out of ideas 'cause I never used M$'s Exchange as LDAP server.

Do you have a ldapsearch command? then try to connect to your Exchange server and check if it works.
If you prefer GUIs, use Netscape browser to connect to the LDAP server, like:
     ldap://ldap_server/cn=Recipients,ou=my_site,o=my_org
Avatar of KNVB HK

ASKER

Ok
What is "ldapsearch command"?
Do you mean perl command?
Well!can give me resource that related to "how to connect exchange server directory service using"?
ASKER CERTIFIED SOLUTION
Avatar of ahoffmann
ahoffmann
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Moondancer
Moondancer

AMINISTRATION WILL BE CONTACTING YOU SHORTLY REGARDING YOUR OPEN AND ABANDONED QUESTIONS, SOME AS OLD AS THE YEAR 2000.

Question(s) below appears to have been abandoned. Your options are:
 
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you. You must tell the participants why you wish to do this, and allow for Expert response.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question. Again, please comment to advise the other participants why you wish to do this.

For special handling needs, please post a zero point question in the link below and include the question QID/link(s) that it regards.
https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process.  https://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Please click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, to track all your open and locked questions at this site.  If you are an EE Pro user, use the Power Search option to find them.

To view your open questions, please click the following link(s) and keep them all current with updates.
https://www.experts-exchange.com/questions/Q.11069265.html
https://www.experts-exchange.com/questions/Q.20075870.html
https://www.experts-exchange.com/questions/Q.20088543.html
https://www.experts-exchange.com/questions/Q.20115980.html
https://www.experts-exchange.com/questions/Q.11641318.html
https://www.experts-exchange.com/questions/Q.20146081.html
https://www.experts-exchange.com/questions/Q.20150364.html
https://www.experts-exchange.com/questions/Q.20180820.html
https://www.experts-exchange.com/questions/Q.20202235.html
https://www.experts-exchange.com/questions/Q.20226705.html
https://www.experts-exchange.com/questions/Q.20251551.html
https://www.experts-exchange.com/questions/Q.20255676.html
https://www.experts-exchange.com/questions/Q.20262636.html
https://www.experts-exchange.com/questions/Q.20272875.html


To view your locked questions, please click the following link(s) and evaluate the proposed answer.
https://www.experts-exchange.com/questions/Q.11483199.html

PLEASE DO NOT AWARD THE POINTS TO ME.  
 
------------>  EXPERTS:  Please leave any comments regarding your closing recommendations if this item remains inactive another seven (7) days.  Also, if you are interested in the cleanup effort, please click this link https://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643
 
Thank you everyone.
 
Moondancer
Moderator @ Experts Exchange

P.S.  For any year 2000 questions, special attention is needed to ensure the first correct response is awarded, since they are not in the comment date order, but rather in Member ID order.
cstsang,

It seems that you made it a habit not resolving your old questions.

You are requeried to follow the instructions I gave you at https://www.experts-exchange.com/questions/20410648/My-Monitor-Shakes-Alot.html !!!

Please consider this as last warning!

If you don't resolve ALL your old open questions within the next 72 Hrs, then steps will be taken to permanently suspend your account at EE.

To see the full list of your open questions, click on your member name link, located at the top left corner of each page, or click on the following links:
First asked questions page: https://www.experts-exchange.com/memberProfile.jsp?mbr=cstsang
Second asked questions page: https://www.experts-exchange.com/memberProfile.jsp?mbr=cstsang&showQHistory=true&qAskBegin=51&qAskEnd=100#1

If you need any help resolving the questions, you should post a 0 (zero) points question at Community Support Topic Area https://www.experts-exchange.com/Community_Support/ and we'll be happy to assist.

Thank you,

RotaredoM
CS Mod @ EE
Nothing has happened on this question in over 12 months.
I will leave a recommendation in the Cleanup topic area that
the answer by ahoffman be accepted (A for effort even if no
complete solution was found).

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer