.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Kaviya Balasubramanian
Imran Ghani
Post New Web Links

hurry! some quesstion about AD ,thx

Posted By:      Posted Date: October 18, 2010    Points: 0   Category :ASP.Net
 

hi !

  I need to Login to a AD , and  there are to DC ,  now I can get a  right resut use these above code :

 private bool IsAuthenticated(String username, String pwd)
    {
      ;

      String server = ConfigurationManager.AppSettings["ADServer"];//192.168.18.201
      String path = ConfigurationManager.AppSettings["ADPath"];//smallbusiness.com
      String domainAndUsername = username;
      DirectoryEntry entry;
      entry = new DirectoryEntry(@"LDAP://" + server ,"DC=smallbusiness,DC=com,"+"cn="+ domainAndUsername, pwd, AuthenticationTypes.Secure);
      try
      {
          Object obj = entry.NativeObject;
          DirectorySearcher search = new DirectorySearcher(entry);
          search.Filter = "(SAMAccountName=" + username + ")";
          search.PropertiesToLoad.Add("cn");
          SearchResult result = search.FindOne();
          if (result == null)
          {
              return false;
          }
        
          return true;
      }
      catch (Exception ex)
      {
          throw new Exception(ex.Message);
         
          return false;
      }
    } 


but I dont know how to use the DC 'smallbusiness.com' to Check Account, now , I can get a right result without the DC, how to do it?

and ,I u


View Complete Post


More Related Resource Links

Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend