Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Nadezhda Ivanova
OpenLDAP
Commits
91f67921
Commit
91f67921
authored
Jan 28, 1999
by
Kurt Zeilenga
Browse files
Add dn_rdn() function to return rdn part of dn.
parent
1d70b892
Changes
2
Hide whitespace changes
Inline
Side-by-side
servers/slapd/dn.c
View file @
91f67921
...
...
@@ -220,6 +220,77 @@ dn_parent(
return
(
ch_strdup
(
""
)
);
}
char
*
dn_rdn
(
Backend
*
be
,
char
*
dn
)
{
char
*
s
;
int
inquote
,
gotesc
;
if
(
dn
==
NULL
)
{
return
NULL
;
}
while
(
*
dn
&&
SPACE
(
*
dn
))
{
dn
++
;
}
if
(
*
dn
==
'\0'
)
{
return
(
NULL
);
}
if
(
be_issuffix
(
be
,
dn
)
)
{
return
(
NULL
);
}
dn
=
ch_strdup
(
dn
);
/*
* no =, assume it is a dns name, like blah@some.domain.name
* if the blah@ part is there, return some.domain.name. if
* it's just some.domain.name, return domain.name.
*/
if
(
strchr
(
dn
,
'='
)
==
NULL
)
{
if
(
(
s
=
strchr
(
dn
,
'@'
))
==
NULL
)
{
if
(
(
s
=
strchr
(
dn
,
'.'
))
==
NULL
)
{
return
(
dn
);
}
}
*
s
=
'\0'
;
return
(
dn
);
}
/*
* else assume it is an X.500-style name, which looks like
* foo=bar,sha=baz,...
*/
inquote
=
0
;
for
(
s
=
dn
;
*
s
;
s
++
)
{
if
(
*
s
==
'\\'
)
{
if
(
*
(
s
+
1
)
)
{
s
++
;
}
continue
;
}
if
(
inquote
)
{
if
(
*
s
==
'"'
)
{
inquote
=
0
;
}
}
else
{
if
(
*
s
==
'"'
)
{
inquote
=
1
;
}
else
if
(
DNSEPARATOR
(
*
s
)
)
{
*
s
=
'\0'
;
return
(
dn
);
}
}
}
return
(
dn
);
}
/*
* dn_issuffix - tells whether suffix is a suffix of dn. both dn
* and suffix must be normalized.
...
...
servers/slapd/proto-slap.h
View file @
91f67921
...
...
@@ -105,6 +105,7 @@ void connection_activity LDAP_P(( Connection *conn ));
char
*
dn_normalize
LDAP_P
((
char
*
dn
));
char
*
dn_normalize_case
LDAP_P
((
char
*
dn
));
char
*
dn_parent
LDAP_P
((
Backend
*
be
,
char
*
dn
));
char
*
dn_rdn
LDAP_P
((
Backend
*
be
,
char
*
dn
));
int
dn_issuffix
LDAP_P
((
char
*
dn
,
char
*
suffix
));
int
dn_type
LDAP_P
((
char
*
dn
));
char
*
dn_upcase
LDAP_P
((
char
*
dn
));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment