.net core修改页面返回的StatusCode,用来验证emqx的用户登陆

.net core修改页面返回的StatusCode,用来验证emqx的用户登陆

public string Re()
        {


            byte[] val1 = { 5, 10, 15, 20, 25, 30 };
            string str = Convert.ToBase64String(val1);
           
            byte[] val2 = Convert.FromBase64String(str);
            Response.StatusCode = 589;
            return val2.ToString();

        }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
在 Linux 环境下使用 .NET Core 修改 AD 域用户密码,可以使用 `System.DirectoryServices.AccountManagement` 命名空间提供的 API。下面是示例代码: ```csharp using System; using System.DirectoryServices.AccountManagement; namespace ChangePassword { class Program { static void Main(string[] args) { try { // 创建 PrincipalContext 对象,连接到 AD 域 using (var context = new PrincipalContext(ContextType.Domain, "your-domain.com", "CN=Administrator,CN=Users,DC=your-domain,DC=com", "password")) { // 获取指定用户的 Principal 对象 var user = UserPrincipal.FindByIdentity(context, IdentityType.SamAccountName, "testuser"); if (user != null) { // 修改用户密码 user.SetPassword("new-password"); user.Save(); Console.WriteLine("Password changed successfully."); } else { Console.WriteLine("User not found."); } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } } } ``` 其中,`PrincipalContext` 构造函数的第一个参数指定 AD 域的类型,第二个参数指定 AD 域的名称,第三个参数指定连接 AD 域所需的用户名,第四个参数指定连接 AD 域所需的密码。 `UserPrincipal.FindByIdentity` 方法用于获取指定用户的 `UserPrincipal` 对象,其中第一个参数指定查询条件的类型,第二个参数指定查询条件的值,第三个参数指定查询的用户名称。 `UserPrincipal.SetPassword` 方法用于修改用户密码,其中参数为新密码。 最后,调用 `UserPrincipal.Save` 方法将修改保存到 AD 域中。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

谁取了我的孔仔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值