• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 481
  • Last Modified:

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?

thanks
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("****", ***); 

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

Open in new window

0
SirReadAlot
Asked:
SirReadAlot
  • 2
2 Solutions
 
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("10.1.1.220", 389); // 389 is the default port.        

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

thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now