none
Active Directory Authentication RRS feed

  • Question



  • hi folks,

    I hav some issues with authenticating users stored in Active Directory Datastore as follows:
    ** The following piece of code works fine ,without any issues.

     public bool IsAuthenticated(string domain, string username, string pwd)
            {

                DirectoryEntry entry = new DirectoryEntry();

                entry.Path = "LDAP://Thiru.server.avonmobility.com:389/DC=thiru,DC=server,DC=avonmobility,DC=com";
              
                try
                {
                    //Bind to the native AdsObject to force authentication.
                    object obj = entry.NativeObject;

                    DirectorySearcher search = new DirectorySearcher(entry);

                  
                    search.Filter = "(&(objectClass=user) (cn=" + username + "))";
                    search.SearchScope = SearchScope.Subtree;
                    search.PropertiesToLoad.Add("cn");
                   
                    SearchResult result = search.FindOne();

                  
                    if (null != result)
                    {
                        string res = result.GetDirectoryEntry().Properties["department"][0].ToString();
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                   
                }
                catch (DirectoryServicesCOMException ex)
                {
                    throw new Exception("Error authenticating user. " + ex.Message);
                }
            }







    ** The following set of codes give error message as follows:
    System.DirectoryServices.DirectoryServicesCOMException ,"Logon failure: unknown user name or bad password".

    try
            {
             DirectoryEntry de = new DirectoryEntry("LDAP://Thiru.server.avonmobility.com:389/CN=Test2,DC=thiru,DC=server,DC=avonmobility,DC=com", "Test2", "test234!");

              Object obj = de.NativeObject;

                DirectorySearcher search = new DirectorySearcher(de);

                string username = "Test2";

                search.Filter = "(&(objectClass=user) (cn=" + username + "))";

                search.PropertiesToLoad.Add("cn");

                SearchResult result = search.FindOne();

                if (result == null)
                {
                    Label1.Text = "Invalid";
                }

                else
                {
                    Label1.Text = "valid";
                }
               
            }
            catch (Exception ex)
            {
            }

    "
    Test2" is the user I HAV CREATED IN ACTIVE DIRECTORY DATASTORE AND ITS PASSWORD IS "test234!".

    I hav replaced
    " Thiru.server.avonmobility.com:389" with "localhost:389" again it fails.

    Pls help me out .
    Thanks in advance.

    Regards,
    thiru.
    Monday, October 20, 2008 8:18 AM

Answers

  • Hi Thiru,

     

    This forum is geared towards software developers to get their applications compatible and certified with Windows Server 2008.

     

    However, I was trying to get some information to help you on this. I discussed with different teams on this and the updates which I received are as follows :

     

    -       Are using ADAM or "Active Directory" ?

     

    -       Is the problem only for one user or multiple users?

     

    -       If multiple, then the coding might be wrong.

     

    -       If one user or few users only, there could be problem with that one account, in which case you should look into the user properties or open a case with the Microsoft Support if you think everything is right but still you are getting the problem

     

    Trouble-shooting is beyond the scope of the forum so in that case you need to contact Microsoft PSS and open a case with your partner account and work with the concerned team.

     

    Hope it helps.

     

    Thanks,

    Leena

    Monday, October 27, 2008 3:05 PM

All replies

  • Hi
    I really wonder ,Is no one out there
    from Microsoft to clarify my doubt or at least to pass some comments on my query.

    regards,
    thiru.
    Wednesday, October 22, 2008 4:57 AM
  • Hi Thiru,

     

    This forum is geared towards software developers to get their applications compatible and certified with Windows Server 2008.

     

    However, I was trying to get some information to help you on this. I discussed with different teams on this and the updates which I received are as follows :

     

    -       Are using ADAM or "Active Directory" ?

     

    -       Is the problem only for one user or multiple users?

     

    -       If multiple, then the coding might be wrong.

     

    -       If one user or few users only, there could be problem with that one account, in which case you should look into the user properties or open a case with the Microsoft Support if you think everything is right but still you are getting the problem

     

    Trouble-shooting is beyond the scope of the forum so in that case you need to contact Microsoft PSS and open a case with your partner account and work with the concerned team.

     

    Hope it helps.

     

    Thanks,

    Leena

    Monday, October 27, 2008 3:05 PM

  • Hi ,
    Something is better than nothing.
    Thanks Leena.
    Wednesday, October 29, 2008 4:43 AM