'/'应用程序中的服务器错误。活动目录

时间:2016-09-28 19:22:22

标签: asp.net active-directory

ASP.NET - C#和Active Directory

(之前的错误PW错误是'SQL Server Express数据库文件自动创建错误',但现在是'/'应用程序'中的服务器错误)

只有在大约10秒或更长时间或使用时钟后使用错误的PW对远程Active Directory进行身份验证时,才会出现此错误。使用正确的用户ID和PW时没有错误或时钟。

任何方向都会受到赞赏,因为我无法在任何地方找到任何解决方案。

其他人有同样的错误,但没有真正的解决方案:http://www.44342.com/dotnet-framework-f1218-t1192-p1.htm

来源错误:

  

在执行当前Web请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息。

     

堆栈追踪:

     

[SqlException(0x80131904):建立与SQL Server的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。 (提供程序:SQL网络接口,错误:26 - 查找指定的服务器/实例时出错)]

     

System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity,SqlConnectionString connectionOptions,SqlCredential credential,Object providerInfo,String newPassword,SecureString newSecurePassword,Boolean redirectedUserInstance,SqlConnectionString userConnectionOptions,SessionData reconnectSessionData,DbConnectionPool pool,String accessToken,Boolean applyTransientFaultHandling) 970
  System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions选项,DbConnectionPoolKey poolKey,Object poolGroupProviderInfo,DbConnectionPool池,DbConnection owningConnection,DbConnectionOptions userOptions)+458      System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection,DbConnectionPoolGroup poolGroup,DbConnectionOptions userOptions)+38      System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection,TaskCompletionSource 1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +507 System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource 1 retry,DbConnectionOptions userOptions)+154      System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection,DbConnectionFactory connectionFactory,TaskCompletionSource 1 retry, DbConnectionOptions userOptions) +21 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource 1 retry)+141      System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)+362      System.Data.SqlClient.SqlConnection.Open()+96      System.Web.Management.SqlServices.GetSqlConnection(String server,String user,String password,Boolean trusted,String connectionString)+75

     

[HttpException(0x80004005):无法连接到SQL Server   数据库]
  System.Web.Management.SqlServices.GetSqlConnection(String server,   String user,String password,Boolean trusted,String   connectionString)+125
  System.Web.Management.SqlServices.SetupApplicationServices(字符串   server,String user,String password,Boolean trusted,String   connectionString,String database,String dbFileName,SqlFeatures   功能,布尔安装)+89
  System.Web.Management.SqlServices.Install(String database,String   dbFileName,String connectionString)+29
  System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile(字符串   fullFileName,String dataDir,String connectionString)+386

我过去也使用过PrincipalContext,并且在密码错误时出现了类似的错误。

这是我目前使用的代码:

public static string fValidUser2(string sUser, string sPW)
    {
        string sDomain_LDAP = "LDAP://domain.com";

        try
        {
            DirectoryEntry entry = new DirectoryEntry(sDomain_LDAP, sUser, sPW);
            object nativeObject = entry.NativeObject;
            return "FOUND";
        }
        catch (DirectoryServicesCOMException cex)
        {
            //not authenticated; reason why is in cex
    return "NOT FOUND";
        }
        catch (Exception ex)
        {
            //not authenticated due to some other exception [this is optional]
    return "NOT FOUND";
        }
    }

来自:

protected void Unnamed6_Click(object sender, EventArgs e)
    {

            string sUserState = clActiveDirectory.fValidUser2(this.frameLogin.UserName, this.frameLogin.Password);

            if (sUserState == "FOUND")
            {
                Session["name"] = this.frameLogin.UserName; 

                FormsAuthentication.SetAuthCookie(this.frameLogin.UserName, createPersistentCookie: false); 

                Response.Redirect("/Default.aspx")
            }
            else
            {

                string sErr = sUserState;
                this.lblStatus.Text = sErr;
                sErr = sErr.Replace("\t", string.Empty);
                sErr = sErr.Replace("\n", string.Empty);
                sErr = sErr.Replace("\r", string.Empty);
                string sRedirect = "~/Error.aspx?error=Login: " + sErr;
                Response.Redirect(sRedirect, false);

            }

}

它以及时的方式处理 - 给我一个“NOT FOUND”返回,处理所有代码然后计时,最后从这个位置呈现SQL Server Express数据库文件自动创建错误Active Directory错误:{{1} }

0 个答案:

没有答案