sharepoint 修改AD密码

下面是添加添加“空元素”代码:

第一个<CustomAction>是添加修改密码项目

第二个<CustomAction>是添加js修改脚本

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction
      Id="{F93B1F84-1DBE-4C10-82E3-2CA47346359E}"
      Title="修改密码"
      Description="此处修改的是域里面的密码"
      Sequence="1000"
      Location="Microsoft.SharePoint.StandardMenu"
      GroupId="PersonalActions"
      ImageUrl="~sitecollection/_layouts/images/menulistsettings.gif">
    <UrlAction Url="javascript:portal_openModalDialog();"/>
  </CustomAction>
  <CustomAction Id="ScriptLink.jQuery"
                Title="ScriptLink.jQuery"
                Location="ScriptLink"
                ScriptBlock=" function portal_openModalDialog() {
                      var options = SP.UI.$create_DialogOptions();
                      options.width = 500;
                      options.height = 250;
                      options.url = ‘/_layouts/updatepassword.aspx‘;
                      options.dialogReturnValueCallback = Function.createDelegate(null, portal_modalDialogClosedCallback);
                      SP.UI.ModalDialog.showModalDialog(options);
                    }

                    //SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK, 1); //关闭函数
                    function portal_modalDialogClosedCallback(result, value) {
                        if (value == ‘1‘) {
                            SP.UI.Notify.addNotification(‘修改成功‘);
                        }
                        else if(value == ‘0‘){
                            SP.UI.Notify.addNotification(‘修改失败,请重新修改‘);
                        }
                    }

                    function closeDialog() {
                        SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel, 3);
                    }
                  "
   />
</Elements>

以下是update.aspx

using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.DirectoryServices.AccountManagement;

namespace ChangePassword.Layouts
{
    public partial class updatepassword : LayoutsPageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            lblMassage.Text = "";
        }
        private string _userName;
        private string _domainName;
        private PrincipalContext _principalContext;
        private UserPrincipal _userPrincipal;
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            _userName = SPContext.Current.Web.CurrentUser.LoginName;
            if (_userName.IndexOf("\\") > 0)
            {
                try
                {
                    if (_userName.Contains("|"))
                    {
                        _domainName = _userName.Split(‘\\‘)[0].Split(‘|‘)[1];
                    }
                    else
                    {
                        _domainName = _userName.Split(‘\\‘)[0];
                    }
                    _userName = _userName.Split(‘\\‘)[1];
                    _principalContext = new PrincipalContext(ContextType.Domain, _domainName, _userName, txtOldPwd.Text);

                    //这个方法也容易出问题,如果旧密码输入错误,这查找也会出错,
                    _userPrincipal = UserPrincipal.FindByIdentity(_principalContext, _userName);

                    if (_userPrincipal != null)
                    {
                        //这一点容易出错,是有关密码策略的问题
                        //密码不满足密码策略的要求。检查最小密码长度、密码复杂性和密码历史的要求。 (异常来自 HRESULT:0x800708C5)

                        _userPrincipal.ChangePassword(txtOldPwd.Text, txtNewPwd.Text);
                        _userPrincipal.Save();
                        Response.Write(
                            "<script type=\"text/javascript\">window.frameElement.commonModalDialogClose(1, 1);</script>");
                    }
                }
                catch (Exception ex)
                {
                    lblMassage.Text = ex.Message;
                }
            }
        }
    }
}
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="updatepassword.aspx.cs" Inherits="ChangePassword.Layouts.updatepassword" DynamicMasterPageFile="~masterurl/default.master" %>

<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">

</asp:Content>

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<table cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td>旧密码:</td>
        <td><asp:TextBox ID="txtOldPwd" runat="server"></asp:TextBox></td>
    </tr>
     <tr>
        <td>新密码:</td>
        <td><asp:TextBox ID="txtNewPwd" runat="server"></asp:TextBox></td>
    </tr>
     <tr>
        <td>确认密码:</td>
        <td><asp:TextBox ID="txtConfirmPwd" runat="server"></asp:TextBox></td>
    </tr>
    <tr>
        <td><asp:Button ID="btnUpdate" runat="server" Text="修改" OnClick="btnUpdate_Click" /></td>
        <td><asp:Button ID="btnCancel" runat="server" Text="取消" OnClientClick="closeDialog()" /></td>
    </tr>
</table>
<br />
    <asp:Label ID="lblMassage" runat="server" ForeColor="Red" Text=""></asp:Label>
</asp:Content>

<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
修改密码
</asp:Content>

<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server" >
我的应用程序页
</asp:Content>
时间: 2024-08-29 05:34:27

sharepoint 修改AD密码的相关文章

在泛微系统中修改AD密码

参照文档: Windows server 2008 R2 安装AD域证书:https://blog.csdn.net/zhuyongru/article/details/81107839 配置泛微OA支持修改AD密码:https://blog.csdn.net/johnlongyuan/article/details/52092706 作为一个IT技术小白,啃了若干文档之后终于实现了在泛微中修改AD的功能. 1.在2008中制作证书. 安装后打开证书颁发机构 然后根据提示重启电脑.在服务器的IE

SharePoint 修改密码Web Part部署方案

SharePoint 修改密码Web Part部署方案 1. 以管理员身份打开Visual Studio2010,新建项目,模板选择SharePoint2010,平台选择.NET Framework 3.5, 新建空白SharePoint项目,编辑名称changePWD及位置,点击确定. 2. 弹出SharePoint 自定义向导.填写预调试站点,点击验证.验证成功后,选择"部署为场解决方案",点击确定. 3. 右键点击changePWD,添加----新建项,选择可视Web部件pass

通过JAVA开发的修改AD用户的工具,修改AD用户密码时报错

今天遇到1个用户反馈的问题,他们通过JAVA开发了一个工具(修改AD用户密码),在此工具中如果将LDAP指向1台辅助DC时就报错,详细信息如下: 问题描述: ========= 通过JAVA开发的修改AD用户密码的工具,LDAP指向1台辅助域控时,修改用户密码报错,JAVA上报错如下: javax.naming.CommunicationException: simple bind failed: 10.10.10.23:636 [Root exception is javax.net.ssl.

JAVA修改AD域密码_免证书认证

更改用户账户密码,必须要使用ssl方式登录到AD. 网上大部分教程使用TrustStore的方式连接, Hashtable env = new Hashtable(); System.setProperty("javax.net.ssl.trustStore", KEYSTORE); System.setProperty("javax.net.ssl.trustStorePassword", KEYSTORE_PWD); env.put(Context.INITIA

Powershell批量修改AD账户登陆到的计算机

Powershell 批量修改AD账户登陆到的计算机 上个月有个项目中碰到这样一个需求,讲述步骤前先描述下客户的实际情况:因安全考虑需要,域内的计算机之前都已经设置了指定登陆到的计算机,目前的项目是从Lotus邮件系统迁移到Exchange 2010,Lotus工作流迁移到泛微OA,域内账户输入账号和密码后不能登陆到Exchange系统.原因就是设置了账户的登陆到计算机属性,因为Exchange是新上的系统,没在指定范围内,所以需要添加Exchange服务器CAS01,CAS02,Mail,Ma

Windows Azure AD密码自助重置功能介绍

说到windows azure大家并不陌生了,当然azure目前分为国际和国内(世纪互联)两个版本,两个版本的功能其实有很大差别,国际版本的azure的功能比国内版本的azure功能强大,功能多,当然国内的azure的功能一直在更新,需要一定的时间来完善及更新,具体再次就不多介绍了,前段时间看见windows azure国内版本更新了一些功能,所以就来尝试一下,今天呢主要介绍windows azure AD密码自助重置功能. 我们在前面的文章中有介绍,通过在windows2012r2上部署ADF

passwd修改用户密码

语法:passwd[username] 等创建完账户后,默认是没有设置密码的.虽然没有密码,但该账户同样登录不了系统.只有设置好密码后才可以登录系统.在为用户创建密码时,安全起见,请尽量设置复杂一些. 建议按照以下规则设置密码: (1)长度大于10个字符: (2)密码中包含大小写字母数字以及特殊字符 * .& .%等: (3)不规则性(不要出现happy.love.Linux.7758520等等单词或者数字:) (4)不要带有自己名字.公司名字.自己电话.自己生日等. [[email prote

centos7修改root密码

1.重启系统,在下面界面时按e键 2.出现可编辑新内容,按向下键向下滑动,找到ro,并修改为rw 后,在LANG=en_US.UTF-8后面再加init=/bin/sh,结果如下图 3.然后按下ctrl+x键进入单用户模式 4.输入passwd root回车,来修改root密码 5.设置新密码,确认密码(密码太简单就会出现BAD PASSWORD·····) 6.输入touch /.autorelabel回车,更新SELinux参数 4-6步如图 7.输入exec /sbin/init回车,重启

单用户模式修改root密码

单用户模式修改root密码 press any key (看到这个界面的时候键盘上的任意按键以进入GNU GRUB模式) edit CentOS edit kernel 设定从单用户模式启动 boot 在单用户模式中修改密码 单用户模式修改root密码