public int AuthenticateToDomain( string DomainID,
    string Password)
 {
     Store store = Store.GetStore();
        Domain domain = store.GetDomain(DomainID);
        if(domain == null)
     throw new Exception("ERROR:Invalid Domain ID");
        Member member = domain.GetCurrentMember();
        if(member == null)
     throw new Exception("ERROR:Unable locate user");
        DomainService domainSvc = new DomainService();
        Uri uri = DomainProvider.ResolveLocation(DomainID);
        if (uri == null)
     throw new Exception("ERROR:No host address for domain");
        domainSvc.Url = uri.ToString() + "/DomainService.asmx";
        domainSvc.Credentials =
     new NetworkCredential(member.Name, Password);
        try
        {
     domainSvc.GetDomainInfo(member.UserID);
        }
        catch(WebException webEx)
        {
     if (webEx.Status == System.Net.WebExceptionStatus.ProtocolError ||
      webEx.Status == System.Net.WebExceptionStatus.TrustFailure)
     {
      throw new Exception("ERROR: Invalid Credentials");
     }
     else if (webEx.Status == System.Net.WebExceptionStatus.ConnectFailure)
     {
      throw new Exception("ERROR: Domain Connection failed");
     }
     else
      throw webEx;
        }
        return 0;
 }