Home > Archive > LDAP > February 2007 > German special characters cause problems with Net::LDAP
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
German special characters cause problems with Net::LDAP
|
|
| Christian Felsing 2007-02-08, 4:22 am |
| Hello,
I experienced a strange problem with following function and Net::LDAP
--- cut here ---
sub CreateLDAPentry {
my ($uid,$name,$vorname,$st) = @_;
my $salt="/%";
my $pwd=crypt($word, $salt);
my $ldap = Net::LDAP->new ("localhost",async => 0) or die "$@";
my $mesg = $ldap->bind ( "$LDAP_ADM_DN",
password => "$LDAP_ADM_PWD",
version => 3 );
my $DNbranch = "ou=freemail, dc=my, dc=domain";
my @CreateArray;
$CreateArray = [
objectClass => [ "top", "inetOrgPerson" ],
uid => "$uid",
cn => "$vorname $name",
sn => "$name",
gn => "$vorname",
userPassword => "{crypt}$pwd",
st => "$st",
];
my $NewDN = "uid=@$CreateArray[3], ".$DNbranch;
my $result = $ldap->add ( $NewDN, attrs => [ @$CreateArray ] );
if ($result->code) {
LDAPerror ("CreateLDAPentry",$result);
}
$ldap->unbind;
return 0;
}
--- cut here ---
User can enter german special characters for $name, $vorname or $st, eg.
Müller for name, but not for uid. After $ldap->add I get following error:
Return code: 21
Message: LDAP_INVALID_SYNTAX :Some part of the request contained an
invalid syntax. It could be a search
with an invalid filter or a request to modify the schema and the given
schema has a bad syntax.
MessageID: 29
DN:
uid was b.m@quake0.de and did not cause any problems while tested w/o
special characters in other attributes.
Any hints ?
best regards
Christian
| |
| Chris Ridd 2007-02-08, 8:16 am |
| On 8/2/07 8:53, "Christian Felsing" <pug@felsing.net> wrote:
> Hello,
>=20
> I experienced a strange problem with following function and Net::LDAP
>=20
> --- cut here ---
>=20
> sub CreateLDAPentry {
> my ($uid,$name,$vorname,$st) =3D @_;
> my $salt=3D"/%";
> my $pwd=3Dcrypt($word, $salt);
>=20
> my $ldap =3D Net::LDAP->new ("localhost",async =3D> 0) or die "$@";
>=20
> my $mesg =3D $ldap->bind ( "$LDAP_ADM_DN",
> password =3D> "$LDAP_ADM_PWD",
> version =3D> 3 );
>=20
> my $DNbranch =3D "ou=3Dfreemail, dc=3Dmy, dc=3Ddomain";
> my @CreateArray;
> $CreateArray =3D [
> objectClass =3D> [ "top", "inetOrgPerson" ],
> uid =3D> "$uid",
> cn =3D> "$vorname $name",
> sn =3D> "$name",
> gn =3D> "$vorname",
> userPassword =3D> "{crypt}$pwd",
> st =3D> "$st",
> ];
>=20
> my $NewDN =3D "uid=3D@$CreateArray[3], ".$DNbranch;
>=20
> my $result =3D $ldap->add ( $NewDN, attrs =3D> [ @$CreateArray ] );
> if ($result->code) {
> LDAPerror ("CreateLDAPentry",$result);
> }
> $ldap->unbind;
> return 0;
> }
>=20
> --- cut here ---
>=20
> User can enter german special characters for $name, $vorname or $st, eg.
> M=FCller for name, but not for uid. After $ldap->add I get following error:
>=20
> Return code: 21
> Message: LDAP_INVALID_SYNTAX :Some part of the request contained an
> invalid syntax. It could be a search
> with an invalid filter or a request to modify the schema and the given
> schema has a bad syntax.
> MessageID: 29
> DN:
>=20
> uid was b.m@quake0.de and did not cause any problems while tested w/o
> special characters in other attributes.
>=20
> Any hints ?
You should definitely set version =3D> 3 when you create the Net::LDAP object=
,
as that will allow you to use UTF-8 later on. The default is to use LDAPv2,
and you're at the mercy of your server vendor as to what character set they
decided to implement instead of the standard T.61. Just use LDAPv3 and avoi=
d
the problem.
Then you may need to do something to change the characters being passed in
by the user from their character set into UTF-8, and pass those UTF-8
characters to the add operation.
Cheers,
Chris
| |
| Svend Sorensen 2007-02-08, 7:16 pm |
| On 2/8/07, Chris Ridd wrote:
>
> You should definitely set version => 3 when you create the Net::LDAP object,
> as that will allow you to use UTF-8 later on. The default is to use LDAPv2,
> and you're at the mercy of your server vendor as to what character set they
> decided to implement instead of the standard T.61. Just use LDAPv3 and avoid
> the problem.
The default protocol version is LDAPv3 in NET::LDAP 0.33.
Svend
| |
| Chris Ridd 2007-02-08, 7:16 pm |
| On 8/2/07 7:46, "Svend Sorensen" <ssorensen@gmail.com> wrote:
> On 2/8/07, Chris Ridd wrote:
>
> The default protocol version is LDAPv3 in NET::LDAP 0.33.
You're quite right, sorry for the confusion.
Cheers,
Chris
| |
| Andrej Ricnik-Bay 2007-02-08, 7:16 pm |
| > Any hints ?
Could be a data related issue?
Since UTF seems to be the default the question would be
whether what you enter is UTF or rather ASCII with a German
character set ...
> best regards
> Christian
Cheers,
Andrej
|
|
|
|
|