Solved

Using C# to authenticate user against openLDAP

Posted on 2013-01-08
5
1,835 Views
Last Modified: 2013-01-14
We are able to connect to openLDAP using c# but some how not able to authenticate users from OpenLDAP, here is our code., any help is appreciated.

public override bool ValidateUser(string username, string password)
        {
           
            bool isValid = false;

            try
            {
                DirectoryEntry dirEntry = new DirectoryEntry(ConfigurationManager.ConnectionStrings["LDAPConnection"].ConnectionString, "cn=manager,dc=domain,dc=in", "Password", AuthenticationTypes.FastBind);

                DirectorySearcher dsSearch = new DirectorySearcher(dirEntry);
                dsSearch.Filter = "(&(objectClass=mailuser)(mail=" + username + "))";
                SearchResult srResult = dsSearch.FindOne();
                if (srResult != null)
                {

                      isValid = true;
                   
                }

            }
            catch (Exception)
            {
            }


            return isValid;
        }
0
Comment
Question by:Pinemail11
[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
  • 4
5 Comments
 
LVL 14

Expert Comment

by:KoenVosters
ID: 38755071
Since you are using SharePoint, I suppose you are using LDAP already as an authentication. Why would you want to authenticate the user again?

http://www.sharepointboost.com/blog/how-to-configure-claims-based-authentication-for-use-with-an-ldap-provider-in-sharepoint-2010/
0
 

Author Comment

by:Pinemail11
ID: 38755665
Thanks, we are using SP foundation, just want to check, solution proposed by you, will it work with SP foundation.

Thanks
0
 

Author Comment

by:Pinemail11
ID: 38757712
As you know that the default LDAP role provider and membership will work only for Active Directory. SharePoint Foundation doesn't have any other role provider to connect with Open LDAP. We have already tested the scenario.

For connecting a web application to Open LDAP, we have created a custom role provider. LDAP is connecting to the webapplication, we could able to add users through people picker. But they cannot able to login in to the site collection. we believe that users password is not able to resolve while login. The SSHA password encryption is used by Open LDAP. Do SharePoint FBA supports SSHA password format?
0
 

Accepted Solution

by:
Pinemail11 earned 0 total points
ID: 38758952
Quick reply will be appreciated
0
 

Author Closing Comment

by:Pinemail11
ID: 38773865
We want to close down the service, hence closing the question.

Overall not happy with the responses from expert-exchange. please note this feedback is not specific to this question, it is general observation.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In case you ever have to remove a faulty web part from a page , add the following to the end of the page url ?contents=1
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

710 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