Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to read info. from Netscape LDAP server

Status
Not open for further replies.

addsd

Programmer
Oct 12, 2001
33
0
0
US
Hi,

I want to read records from LDAP server. Could u please show me some code as how to connect to LDAP server and read records from ASP

I have a HTML form where user input a string which contain in "FirstName" of employee. Upon clicking of search button, I'm calling an ASP where I need script for connecting to LDAP and get all the records those are matching with user input "string"

Many thanks in advance for your help..

Rgds - Ahmed
 
hello,

if you are using netscape directory server try using ldapsearch under .../netscape/suitespot/bin/slapd/server/

here's the syntax:

./ldapsearch -b "ou=..." -h localhost -p portNumber -D "cn=Directory Manager" "FirstName=..."

try this in your script...

hth,
q.
 
Hi,

Thanks for your reply...

I'm not sure about how to write the script to access Netscape LDAP server. I tried earlier with following but, I'm getting an error message of "table doesn't exist..."

mSQL = "select cn from 'LDAP://190.20.67.33/o=xyz.com/ou=abc-co' where
objectClass ='*'"
cn1.Provider = "ADsDSOObject"
cn1.Open "ADs Provider", "ou=abc-co,o=xyz.com"

Set rs1 = cn1.Execute(mSQL)

Could you please help me on writing a script with parameter you have shown in your reply...

appreciate your kind help...

rgds - Ahmed

Now
 
hello,

try this perl wrapper script...

#! /usr/bin/perl
while ($#ARGV >= 0)
{
($_, $val) = splitArgument($ARGV[0]);

SWITCH:
{
if (/^passwd$/) { $password = $val; last SWITCH }
if (/^attribute$/) { $attributeName = $val; last SWITCH }
if (/^value$/) { $attributeValue = $val; last SWITCH }
if (/^out$/) { $out = $val; last SWITCH }
}

shift ARGV;
}

system (`/usr/netscape/suitespot/bin/slapd/server/ldapsearch -b "ou=Name,o=Name" -h localhost -p portNumber -D "cn=Directory Manager" -w $password "$attributeName=$attributeValue">$out`);

sub splitArgument
{
return split(/=/, $_[0]);
}

----

here's the command line execution of the script

./query.pl passwd=password attribute=FirstName value=John out=output.txt

hth,
q.
 
Hi,

Thanks for your help.... But, I don't know the script you written. Is it Pearl or C++ ?.

I' need write VBscript ot JavaScript to get the records from LDAP. Could you please show me exapmples ....

Appreciate your help ...

Rgds - Ahmed
 
hello,

the script is in perl... i'm not sure how you write it in vbscript/javascript... but you just need to pass in your password, attribute type, attribute value and out file name as parameters, and then do a system execute of the ldapsearch utility passing in the parameters to the appropriate ldapsearch switches... in unix shell scripts the tik marks are used to execute system commands... i'm not sure how you do it in vbscript or javascript...

sorry, i can't be of much more help,

q.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top