Querying Ldap ou folders with c#

Hi Experts,

I have this piece of code which querys one OU Folder and works. how do i query two OU folders to ensure that all users are accounted for?
 string userDN = "CN=" + Username.Value + ", OU=IS, OU=TY  O=HCFHE"; // Change to match your Distinguished Name (DN)

Also why is it that just the parent [O=HCFHE] can not be queried?

protected void Login_Click(object sender, EventArgs e)
       string userDN = "CN=" + Username.Value + ", OU=IS,  O=HCFHE"; // Change to match your Distinguished Name (DN)
       LdapConnection ldapConn = new LdapConnection();
        ldapConn.Connect("****", ***); 

            ldapConn.Bind(userDN, Password.Value);
            FormsAuthentication.RedirectFromLoginPage(Username.Value, PersistCookie.Checked);
        catch (LdapException)
            lblMsg.Text = "Incorrect username/password combination.";

Open in new window

Who is Participating?
SirReadAlotAuthor Commented:
How do I query multiple OUS

  if ((userDN = "CN=" + Username.Value + ", OU=IS,  O=HCFHE") || (userDN = "CN=" + Username.Value + ", OU=EaST,  O=HCFHE"))
              LdapConnection ldapConn = new LdapConnection();
              ldapConn.Connect("", 389); // 389 is the default port.        

Error      1      Operator '||' cannot be applied to operands of type 'string' and 'string'      

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.