Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I have a code below to connect ldap server but its giving me the following exception.

C#
private void btnLogin_Click(object sender, EventArgs e)
      {
          string strUsername, strPassword, strDomain;
          strUsername = txtUsername.Text;
          strPassword = txtPassword.Text;
          strDomain = txtDomain.Text;
          if (strUsername == "")
              MessageBox.Show("Enter Username");
          else if (strPassword == "")
              MessageBox.Show("Enter Password");
          else if (strDomain == "")
              MessageBox.Show("Enter Domain");
          else
          {
              strDomain = "LDAP://" + strDomain;
              using (DirectoryEntry deDirEntry = new DirectoryEntry(strDomain,
                                                        strUsername,
                                                         strPassword, AuthenticationTypes.Secure))
              {
                  // if user is verified then it will welcome then
                  try
                  {
                      MessageBox.Show("Welcome to '" + deDirEntry.Name + "'");

                      // TODO: add your specific tasks here
                  }
                  catch (Exception exp)
                  {
                      MessageBox.Show("Sorry, unable to verify your information"+exp);
                  }
              }
          }
      }


And below is the exception i am getting.

C#
System.Runtime.InteropServices.COMException (0x8007203A): The server is not operational.

   at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
   at System.DirectoryServices.DirectoryEntry.Bind()
   at System.DirectoryServices.DirectoryEntry.get_Name()
   at ldap.frmLdap.btnLogin_Click(Object sender, EventArgs e) in C:\Documents and Settings\divyar.DNISC\my documents\visual studio 2010\Projects\ldap\ldap\frmLdap.cs:line 41



i think its getting connected but not getting bind? how to solve this? Thanks in advance
Posted
Comments
Ron Beyer 24-Apr-13 0:09am    
I don't think you are forming your LDAP URL correctly, see the following for some examples:
http://msdn.microsoft.com/en-us/library/system.directoryservices.directoryentry.path.aspx
http://stackoverflow.com/questions/1405011/ldap-directory-entry-in-net-not-working-with-ou-users
http://msdn.microsoft.com/en-us/library/x8wxt72e(v=vs.71).aspx
Member 9762654 24-Apr-13 0:18am    
i am very new to ldap my domain is 190.167.9.68 username is xxxxxx password is yyyyyy company is abc-def.com then how can i form ldap url pls help

1 solution

Please Check this The Server Is Not Operational
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900