LDAP path in web.config???



Hi can someone please tell me why I can't put the following LDAP path into
my web.config fill as an <appSetting> and how do I get it to work!

<add key="strLDAP" value="'LDAP://doamin.domain.com', 'Administrator',
'Password'" />

The connection string doesn't work when I call it in the code as shown


But this works fine if I put it straight into the code!
DirectoryEntry("LDAP://" & strADPath, "Administrator", "Password")

I don't get it... It is the same thing????

Could someone please give me some advice!




Paul Glavich [MVP ASP.NET]

No, its not the same thing. Your appSetting contains the single apostraphe,
whereas the one in code doesn't, so your actually passing the start and end
single apostraphies as part of the connection string.

ie. using the config setting, you are passing in this
'LDAP://doamin.domain.com', 'Administrator', 'Password'

instead of this


not to mention you have the user and pwd included in the first version.

My suggestion is to split the appSetting into the LDAP part, a user part and
the password part, and concatenate them in code, that way you dont have to
bother including any surrounding apostraphies or anything like that. (Not to
mention also encrypting the username/password so its not in clear text)

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question