Solved

Querying Ldap ou folders with c#

Posted on 2010-09-13
3
471 Views
Last Modified: 2013-12-24
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
Comment
Question by:SirReadAlot
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
Kumaraswamy R earned 250 total points
ID: 33662930
0
 

Author Comment

by:SirReadAlot
ID: 33663369
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
 
LVL 29

Assisted Solution

by:Kumaraswamy R
Kumaraswamy R earned 250 total points
ID: 33663890
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question