Solved

Querying Ldap ou folders with c#

Posted on 2010-09-13
3
473 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
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…

730 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