更改过期的密码,而"密码过期对话框" [英] Change expired password without "Password Expired dialog box"

查看:209
本文介绍了更改过期的密码,而"密码过期对话框"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我登录使用SQL Server数据库的登录帐户我的应用程序。但是,当用户的密码已过期,我只能用错误:18488捕获错误消息。并显示一条消息给用户

I'm logging on my application using Sql Server Database logon account. However, when a user's password is expired, i can only catch the error message using "error:18488" and display a message to user.

当我登入使用SQL Server Management Studio和使用过期密码的帐户,将出现一个对话框,要求我更改密码。

When I login using Sql Server Management Studio with an account with expired password, a dialog box requiring me to change password appears.

有没有办法让我的应用程序与类似T-SQL语句更改过期的密码?

Is there a way to allow my application to change the expired password with something like T-Sql statement?

推荐答案

我已经找到了解决方案 ,我用 SqlConnection.ChangePassword()

I've found the solution here, I used SqlConnection.ChangePassword().

这里的code:

class Program
{
    static void Main(string[] args)
    {
        System.Data.SqlClient.SqlConnection.ChangePassword(
        "Data Source=a_server;Initial Catalog=a_database;UID=user;PWD=old_password", 
       "new_password");
    }
}

希望它可以帮助他人。 :)

Hope it helps others too. :)

这篇关于更改过期的密码,而"密码过期对话框"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆