Closed
Bug 1336
Opened 26 years ago
Closed 20 years ago
Problem managing schemas using PerLDAP
Categories
(Directory :: PerLDAP, defect, P4)
Tracking
(Not tracked)
RESOLVED
INVALID
People
(Reporter: leif, Assigned: leif)
Details
From a user:
i'd post this on the directory newsgroup but oracle doesn't allow snntp through
the firewall. i tried to add classes 7 attributes to the ldap schema using
perldap. i get no error but no addition happened either.
i tried translating it in c and it worked. i'm a neophyte when it comes to ldap,
nor have i ever written a perl module, although i'll do my best attempting to
figure out what's going on. should i succeed i'll let you know. in the meantime
i attach both perl and c code. regards,
--
Aaron Stromas : "Tick-tick-tick.... ja, Pantani is weg."
e-mail: astromas@us.oracle.com :
Tel.: +1 703 917 48 72 : BRTN commentator, L'Alpe d'Huez,
Tour de France, 1995
#include <stdio.h>
#include <ldap.h>
#define SLAPD "fnsrvs-sun1.us.oracle.com"
#define PORT 3389
#define ADMIN "cn=Directory Manager"
#define BASE "cn=schema"
#define FILTER "(objectclass=subschema)"
#define OBJ "( 2.1.16.840.1.113730.2.777.1 NAME 'testobject' DESC 'Test Object'
SUP 'person'
MUST ( objectclass $ sn $ uid ) MAY ( aci $ description $ seealso $
telephonenumber $
userpassword $ dbuid $ dbpassword ) )"
#define DBU "( 2.1.16.840.1.113730.2.777.2 NAME 'dbuid' DESC 'Test Attribute'
SYNTAX
'1.3.6.1.4.1.1466.115.121.1.5' )"
#define DBP "( 2.1.16.840.1.113730.2.777.3 NAME 'dbpassword' DESC 'Test
Attribute' SYNTAX
'1.3.6.1.4.1.1466.115.121.1.5' )"
main(int argc, char **argv)
{
LDAP *ld;
LDAPMessage *result, *e;
char c, *a, **vals, *attr, *srch;
BerElement *ber;
LDAPMod mod[2];
LDAPMod *mods[3];
char *ovals[2];
char *avals[3];
int no = 0, na = 0, i, j;
if (argc < 2) {
fprintf(stderr, "usage: %s password\n", argv[0]);
exit(1);
}
if ((ld = ldap_init(SLAPD, PORT)) == NULL) {
perror("ldap_init");
exit(1);
}
if (ldap_simple_bind_s(ld, ADMIN, argv[1]) != LDAP_SUCCESS) {
ldap_perror(ld, "ldap_simple_bind_s");
exit(1);
}
avals[0] = DBU;
avals[1] = DBP;
avals[2] = NULL;
ovals[0] = OBJ;
ovals[1] = NULL;
mod[0].mod_op = LDAP_MOD_ADD;
mod[0].mod_type = "attributetypes";
mod[0].mod_values = avals;
mods[0] = &mod[0];
mod[1].mod_op = LDAP_MOD_ADD;
mod[1].mod_type = "objectclasses";
mod[1].mod_values = ovals;
mods[1] = &mod[1];
mods[2] = NULL;
if (ldap_modify_s(ld, BASE, mods) != LDAP_SUCCESS) {
ldap_perror(ld, "ldap_modify_s");
exit(1);
}
if (ldap_search_s(ld, BASE, LDAP_SCOPE_BASE, FILTER, NULL, 0, &result) !=
LDAP_SUCCESS)
{
ldap_perror(ld, "ldap_search_s");
exit(1);
}
for (e = ldap_first_entry(ld, result); e != NULL; e = ldap_next_entry(ld,
e)) {
for (attr = ldap_first_attribute(ld, e, &ber); attr; attr =
ldap_next_attribute(ld,
e, ber)) {
vals = ldap_get_values(ld, e, attr);
for (j = 0; vals[j]; j++)
if (j)
printf("\t\t%s\n", vals[j]);
else
printf("%s:\t%s\n", attr, vals[j]);
if (!strcmp(attr, "objectclasses"))
no = ldap_count_values(vals);
if (!strcmp(attr, "attributetypes"))
na = ldap_count_values(vals);
ldap_value_free(vals);
ldap_memfree(attr);
}
if (ber)
ber_free(ber, 0);
}
ldap_unbind(ld);
printf("%d Object classes\n%d Attribute types\n", no, na);
exit(0);
}
#!/usr/local/bin/perl -w
use Mozilla::LDAP::Conn;
use Mozilla::LDAP::Utils;
my ($ans1, $dn, $pswd, $file, $obj) = ('2.16.840.1.113730.3.2.777',
'cn=Directory Manager');
while (@ARGV) {
$_ = shift @ARGV;
$dn = shift @ARGV, next if /^-d/;
$ans1 = shift @ARGV, next if /^-i/;
$pswd = shift @ARGV, next if /^-p/;
$obj = shift @ARGV if /^-o/;
}
%ld = Mozilla::LDAP::Utils::ldapArgs();
($ld{host}, $ld{port}, $ld{scope}) = qw(fnsrvs-sun1.us.oracle.com 3389 base);
($ld{'bind'}, $ld{pswd}) = ($dn, $pswd);
my $o = qq/( $ans1 NAME 'testobject' DESC 'Test Object' SUP 'person' MUST / .
q/( objectclass $ sn $ uid) MAY ( aci $ description $ seealso $ / .
q/telephonenumber $ userpassword $ dbuid $ dbpassword ) )/;
my @a = (qq/( ${ans1}.1 NAME 'dbuid' DESC 'Test Attribute' / .
q/SYNTAX '1.3.6.1.4.1.1466.115.121.1.5' )/,
qq/( ${ans1}.2 NAME 'dbpassword' DESC 'Test Attribute' / .
q/SYNTAX '1.3.6.1.4.1.1466.115.121.1.5' )/);
my $conn = new Mozilla::LDAP::Conn(\%ld) || die "Couldn't connect to LDAP server
$ld{host}";
my $entry = $conn->search("cn=schema", "base", "(objeclass=*)");
push @{$entry->{objectclasses}}, $o;
push @{$entry->{attributetypes}}, @a;
$conn->update($entry);
$conn->printError() if $conn->getErrorCode();
$entry = $conn->search("cn=schema", "base", "(objeclass=subschema)");
print "Object classes:\n";
for (@{$entry->{objectclasses}}) {
print "$_\n";
}
print "Object attributes:\n";
for (@{$entry->{attributetypes}}) {
print "$_\n";
}
exit 0;
Assignee | ||
Updated•26 years ago
|
Status: NEW → ASSIGNED
Assignee | ||
Updated•26 years ago
|
Priority: P2 → P4
Clearing "M" field since Directory product is not used for 5.0 specific project
bug metrics and will mess up our queries on milestones.
Comment 3•24 years ago
|
||
This bug has not been touched for more than nine months. In most cases, that
means it has "slipped through the net". Please could the owner take a moment to
add a comment to the bug with current status, and/or close it.
Thank you :-)
Gerv
Assignee | ||
Comment 4•20 years ago
|
||
It's been too long since this was filed, closing now, but please reopen if this
still is a problem. PerLDAP v1.5 is almost ready, and you can get the latest dev
source from CVS (branch devel-branch-1_4_2).
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•