locked
Red Hat Directory Service Integration with ASP DOT NET application RRS feed

  • Question

  • Hi


    We are trying to integrate red hat directory service for authentication of various applications. One of our application's front end is .net and back end is sql server 2008 r2. While trying to configure, its working windows AD but if we try configuring with open LDAP, its not working. Its throwing the message, unable to connect, please try again later. Have provided the set of source code as below

    string UserName = string.IsNullOrEmpty(Request.Params.Get("txtlogin")) ? string.Empty : Request.Params.Get("txtlogin").ToLower();
                string Password = string.IsNullOrEmpty(Request.Params.Get("txtpassword")) ? string.Empty : Request.Params.Get("txtpassword");
                 string DomainName = "LDAP:\\IPAddress";

                AuthenticationStatus = string.IsNullOrEmpty(UserName) ? "ValidationErr- Enter value for the 'User Name' field." : string.IsNullOrEmpty(Password) ?

    "ValidationErr- Enter value for the 'Password' field." : string.IsNullOrEmpty(DomainName) ? "ValidationErr- Select value for the 'Domain Name' field." : string.Empty;
                if (string.IsNullOrEmpty(AuthenticationStatus))
                {
                    //bool isAuthenticated     = AuthenticateUser(UserName, Password, DomainName, out AuthenticationStatus);
                    bool isAuthenticated = AuthenticateUser(UserName, Password, DomainName);
                    //isAuthenticated = true; //Code To be Deleted
                    if (isAuthenticated)
                    {
                        AuthenticationStatus = string.Empty;

     private bool AuthenticateUser(string UserName, string Password, string DomainName)
        {
            bool Flag = false;
            try
            {

                AuthenticationTypes at = AuthenticationTypes.Anonymous;
                at = AuthenticationTypes.Secure;
                DirectoryEntry dirEntry = new DirectoryEntry("LDAP://IPAddress", UserName, Password, at);

               
                //////////////////
                using (DirectoryEntry de = new DirectoryEntry("LDAP://IPAddress"))
                {
                    using (DirectorySearcher adSearch = new DirectorySearcher(de))
                    {
                        adSearch.Filter = "(sAMAccountName=" + UserName + ")";
                        SearchResult adSearchResult = adSearch.FindOne();
                        string name = adSearchResult.Properties["name"][0].ToString();
                        string pass = adSearchResult.Properties["pwdlastset"][0].ToString();

                    }
                }

                //////////////////
                object nat;
                nat = dirEntry.NativeObject;
                Flag = true;
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
                Flag = false;
            }
            return Flag;
        }

    Please check and suggest or provide the code / function / method to integrate with Linux based OS

    • Moved by CoolDadTx Monday, November 30, 2015 3:35 PM Wrong forums
    Monday, November 30, 2015 11:33 AM

Answers

  • You probably need to post to the ASP.NET forum.

    http://forums.asp.net/

    Monday, November 30, 2015 12:44 PM

All replies

  • You probably need to post to the ASP.NET forum.

    http://forums.asp.net/

    Monday, November 30, 2015 12:44 PM
  • Thanks, I have posted in asp.net forum
    Tuesday, December 1, 2015 4:44 AM