Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connection string to connect to Active Directory using LDAP

my system admin gave me this:

Domain : capp.net USER : capp\dhr2

Pass : admin@12345

what will the connection string be?

I am very very new to adfs. So i tried this:

<add name="ADConnectionString"
      connectionString="LDAP://capp.net/CN=dhr,DC=capp,DC=net"  />

<authentication mode="Forms">
  <forms name=".ADAuthCookie" timeout="43200"/>
</authentication>
<authorization>
</authorization>

<membership>
  <providers>
    <clear/>

    <add name="MyADMembershipProvider"
     type="System.Web.Security.ActiveDirectoryMembershipProvider"
     connectionUsername="cn=dhr2"
     connectionPassword="admin@12345"
    connectionStringName="ADConnectionString"/>

  </providers>
</membership>

I am always getting this error: Unable to establish secure connection with the server

I am doing someting wrong with the connection string. I just dont know how to fix it.

like image 987
Newton Sheikh Avatar asked Jan 15 '23 01:01

Newton Sheikh


2 Answers

Whenever I've accessed AD from .net I've done the following:

var directoryEntry = new DirectoryEntry("LDAP://capp.net");
directoryEntry.Username = "capp\dhr2";
directoryEntry.Password = "admin@12345";

Then you can query "AD" using the DirectorySearcher.

var directorySearcher = new DirectorySearcher(directoryEntry);

...

like image 132
SOfanatic Avatar answered Jan 18 '23 23:01

SOfanatic


Thanks to everyone for your help and support. The correct address in my case was:

LDAP://192.168.0.146/CN=USERS,DC=capp,DC=net

What i didnt realize in the beginning was that i was trying to connect to Active Directory in a different domain than my current domain. So the Ip address was the missing part. thanks a million to Luis who realized that there was something wrong was with the domain.

And thanks Shadow Walker for explaining the ldap connection string in more details.

like image 36
Newton Sheikh Avatar answered Jan 19 '23 01:01

Newton Sheikh