LDAP path in web.config???


G

Guest

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!

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

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

DirectoryEntry(ConfigurationSettings.AppSettings("strLDAP"))

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!

Thanks
 
Ad

Advertisements

P

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

LDAP://doamin.domain.com

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

Top