473,651 Members | 2,716 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

LDAP Access from this program

Hi

I have a application to search an entry in the LDAP server.
I tried to run this application and it runs perfectly. But the issue
is I am nnot able to Login to the server and searhc for the entry
"CN=anip,DN=loc alhost,DN=com". It always give me error
ldap_search_ext _s error here.

Can you please let me know what exatly is the kind of error and
possible solution for this.
Here is the code for my application
#include <stdio.h>
#include <stdlib.h>
#include "ldap.h"

//1. Domain Name ..2.3.
//2. Deprartment DP
//3. GROUP - Organization - Module-

/* Adjust these setting for your own LDAP server */
#define HOSTNAME 192.168.1.20
#define PORT_NUMBER LDAP_PORT
#define FIND_DN "CN=anip,DN=loc alhost,DN=com"
// OpenLDAP Project
int main( int argc, char **argv )
{
LDAP *ld;
LDAPMessage *result, *e;
BerElement *ber;
char *a;
char **vals;
int i, rc;

/* Get a handle to an LDAP connection. */
if ( (ld = ldap_init( HOSTNAME, PORT_NUMBER )) == NULL )
{
perror( "ldap_init" );
return( 1 );
}

/* Bind anonymously to the LDAP server. */
rc = ldap_simple_bin d_s( ld, null, null);
if ( rc != LDAP_SUCCESS )
{
fprintf(stderr, "ldap_simple_bi nd_s: %s\n",
ldap_err2string (rc));
return( 1 );
}

/* Search for the entry. */
if ( ( rc = ldap_search_ext _s( ld, FIND_DN, LDAP_SCOPE_BASE ,
"(objectclass=* )", NULL, 0, NULL,
NULL, LDAP_NO_LIMIT,
LDAP_NO_LIMIT, &result ) ) !=
LDAP_SUCCESS )
{
fprintf(stderr, "ldap_search_ex t_s: %s\n",
ldap_err2string (rc));
return( 1 );
}

/* Since we are doing a base search, there should be only
one matching entry. */
e = ldap_first_entr y( ld, result );
if ( e != NULL )
{
printf( "\nFound %s:\n\n", FIND_DN );

/* Iterate through each attribute in the entry. */
for ( a = ldap_first_attr ibute( ld, e, &ber );
a != NULL; a = ldap_next_attri bute( ld, e, ber ) )
{

/* For each attribute, print the attribute name and
values. */
if ((vals = ldap_get_values ( ld, e, a)) != NULL )
{
for ( i = 0; vals[i] != NULL; i++ )
{
printf( "%s: %s\n", a, vals[i] );
}
ldap_value_free ( vals );
}
ldap_memfree( a );
}
if ( ber != NULL )
{
ber_free( ber, 0 );
}
}
ldap_msgfree( result );
ldap_unbind( ld );
return( 0 );
}

Oct 15 '07 #1
1 3984
On Sun, 14 Oct 2007 22:49:33 -0700, in comp.lang.c , Matrixinline
<an**********@g mail.comwrote:
>Hi

I have a application to search an entry in the LDAP server.
I tried to run this application and it runs perfectly. But the issue
is I am nnot able to Login to the server and searhc for the entry
"CN=anip,DN=lo calhost,DN=com" . It always give me error
ldap_search_ex t_s error here.
Your question seems to be about how to use LDAP. This is offtopic
here - I would suggest a better place but I have no idea where.

Also you will need to explain (to the experts in which ever news group
or forum you move to) exactly at what point you get the error, and how
you've checked that nothing went wrong earlier.

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Oct 15 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1342
by: Christian Schuhegger | last post by:
Hi, I remember that I've seen some time ago (perhaps a year or so) a project on freshmeat where a guy hacked a postgres c-interface library (i guess it was libpq / or perhaps he just used the libpq network interface) to allow for runtime access to program state via sql queries. You had to register variables that you want to make available my the sql interface with the library and then you could query the program state while the program...
5
1770
by: Henry Jordon | last post by:
hello I was wondering if someone could help me get a main going on this project I've completed the header file that the professor started us on but not really sure how to get the main going. If someone could please give me some pointers it would greatly be appreciated. Again thanks for the help. Henry headerfile:
7
3060
by: Leonardo D'Ippolito | last post by:
Hello all, I need to get the MAC ADDRESS of a NIC without using WMI. Microsoft has this piece of code in their knowledge base: http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q118623 How can I access this kind of funtion from a C# program? An example would be great...
4
1935
by: silverburgh.meryl | last post by:
I am currently access this newsgroup thru Google group web interface. Is it possible to access this newsgroup using Thunderbird? Thank you.
4
1680
by: switzerland qunatium computer | last post by:
Machine intelligence- can this program be written ?? Machine intelligence- can this program be written ??
6
2601
by: khajeddin | last post by:
this program print its own source code without opening the source file. would some one please explain me how does it work ,and what what process takes place in this program???? #include <stdio.h> char *program = "#include <stdio.h>%cchar *program = %c%s%c;%cint main()%c{%c%cprintf(program, 10, 34, program, 34, 10, 10, 10, 9, 10, 9, 10, 10,10);%c%creturn 0;%c}%c"; int main() { printf(program, 10, 34, program, 34, 10, 10, 10, 9,...
11
1949
by: compsci | last post by:
Write a program that uses functions to calculate a person’s paycheck. The program should ask for a person’s first and last name, social security number (use fakes), phone number, address, hours worked (in the week), and hourly wage. The program should also include overtime (time and a half) if they have worked more than 40 hours. The program should also take out federal taxes (8%). The program should display the results to the screen. The...
3
1113
by: r.e.s. | last post by:
Can the following program be shortened? ... def h(n,m): E=n, while (E!=())*m>0:n=h(n+1,m-1);E=E+(E>0)*(E-1,)*n return n h(9,9) Note: Although it halts eventually in principle, this program can't be expected to terminate on any machine in the universe, as it computes a
82
3671
by: Bill David | last post by:
SUBJECT: How to make this program more efficient? In my program, a thread will check update from server periodically and generate a stl::map for other part of this program to read data from. Let's name the update method as doUpdate and stl::map read methods as getData and copyData. Since stl::map is not thread-safe, we should do synchronization by ourselves. A usable solution is to create a boost::mutex::scoped_lock object in all above...
30
2252
by: Anarki | last post by:
The following is the program i am trying to compile //restrict.c #include <stdio.h> int main() { char arr = "Qualifiers" char * restrict p = arr; int i = 0; for(; i < 10; ++i)
0
8352
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8802
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8465
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8579
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7297
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4283
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1909
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1587
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.