D
D
DanSab2012-09-09 21:20:14
bash
DanSab, 2012-09-09 21:20:14

Why is ldapsearch so weird?

#! /bin/bash

ldapurl="ldap://ad.local.lan:389"
basedn="OU=some,DC=local,DC=lan"
binddn="CN=someuser,OU=piter,DC=local,DC=lan"
ldappas="somepass"

ldapsrc="ldapsearch -LLL -H \"$ldapurl\" -b \"$basedn\" -D \"$binddn\" -w \"$ldappas\""
$ldapsrc


Output:
Could not parse LDAP URI(s)="ldap://ad.local.lan:389" (3)

Moreover, if you write
echo $ldapsrc

and manually execute what echo returns - everything is fine.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
ansl, 2012-09-18
@ansl

You don't use spaces in any of your variables, so you don't need the inner quotes.

ldapsrc="ldapsearch -LLL -H $ldapurl -b $basedn -D $binddn -w $ldappas"
$ldapsrc

Y
Yuriy Andamasov, 2012-09-10
@syncer

Try single quotes
ldapsrc='ldapsearch -LLL -H \"$ldapurl\" -b \"$basedn\" -D \"$binddn\" -w \"$ldappas\"'

S
S1ashka, 2012-09-10
@S1ashka

and escape slashes in ldap://ad.local.lan:389

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question