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=""
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 = ;
options.height = ;
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 == '') {
SP.UI.Notify.addNotification('修改成功');
}
else if(value == ''){
SP.UI.Notify.addNotification('修改失败,请重新修改');
}
} function closeDialog() {
SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel, );
}
"
/>
</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("\\") > )
{
try
{
if (_userName.Contains("|"))
{
_domainName = _userName.Split('\\')[].Split('|')[];
}
else
{
_domainName = _userName.Split('\\')[];
}
_userName = _userName.Split('\\')[];
_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="" cellspacing="" border="">
<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>

sharepoint 修改AD密码的更多相关文章

  1. 在泛微系统中修改AD密码的配置

    参照文档: Windows server 2008 R2 安装AD域证书:https://blog.csdn.net/zhuyongru/article/details/81107839 配置泛微OA ...

  2. Python 修改AD密码

    前提条件: AD 已开启证书服务(最重要的一句话). import ldap3 SERVER = 'adserver' BASEDN = "DC=example,DC=com" U ...

  3. 烦烦烦SharePoint2013 以其他用户登录和修改AD域用户密码

    sharepoint默认是没有修改AD密码 和切换 用户的功能,这里我用future的方式来实现. 部署wsp前: 部署后 点击以其他用户身份登录 点击修改用户密码: 这里的扩展才菜单我们用Custo ...

  4. SharePoint2013 以其他用户登录和修改AD域用户密码 功能

    sharepoint默认是没有修改AD密码 和切换 用户的功能,这里我用future的方式来实现. 部署wsp前: 部署后: 点击以其他用户身份登录 点击修改用户密码: 这里的扩展才菜单我们用Cust ...

  5. SharePoint中修改密码的WEB Part之终极版:即可以修改AD,又可以修改本机用户密码的Web Part!!

    转:http://www.cnblogs.com/dosboy/archive/2007/08/01/838859.html 在网上查了那么多SharePoint密码修改的第三方开发,都有问题.总结下 ...

  6. sharepoint修改密码

    增加SharePoint2010修改域密码功能 前提SharePoint2010的用户基于AD的,因此修改密码是修改了AD的密码,当然也可以修改本机密码(非域的密码).这里我们讨论修改域密码.我们修改 ...

  7. java修改AD域用户密码使用SSL连接方式

    正常情况下,JAVA修改AD域用户属性,只能修改一些普通属性, 如果要修改AD域用户密码和userAccountControl属性就得使用SSL连接的方式修改, SSL连接的方式需要操作以下步骤: 1 ...

  8. C#修改AD账号及密码

    在使用AD域环境搭建的账号系统修改密码的时候比较麻烦一般需要管理员在域环境去进行对用户的密码进行修改. 以下就是用来查询和修改AD域密码的方法. 1 /// <summary> 2 /// ...

  9. 增加SharePoint2010修改域密码功能

    转:http://blog.163.com/hr_test/blog/static/16485210720137953131694/ 前提 SharePoint2010的用户基于AD的,因此修改密码是 ...

随机推荐

  1. 献给所有从事IT行业拥有梦想的英语渣们

    本文适合读者:从小到大英语都不好,如今选择IT行业需要重拾英语追寻梦想的人,英语大神们请绕行.. 目录 一.背景介绍 二.明确学习目标 2.1 英文文法 2.2 词汇量 三.题外话 3.1 关于本文 ...

  2. 学习网页制作中如何在正确选取和使用 CSS 单位

    在 CSS 测量系统中,有好几种单位,如像素.百分比.英寸.厘米等等,Web 开发人员很难了解哪些单位在何处使用,如何使用.很多人习惯了总是使用同一种单位,但这一决定可能会严重限制你的设计的执行. 这 ...

  3. Java性能优化

    作者:禅楼望月(http://www.cnblogs.com/yaoyinglong) 注:里面的测试结果会因电脑配置的不同而有所差异!!! 1. 为一些集合定义初始化大小 List.Set.Map都 ...

  4. 谷歌插件Image downloader开发之popup

    Image downloader的交互逻辑是这样的:用户点击Image downloader的图标,会向页面(content script,见上一篇文章:谷歌插件Image downloader开发之 ...

  5. [Java 进阶]异常

    异常:程序在运行过程中发生由于硬件设备问题.软件设计错误等导致的程序异常事件. 世上没有百分之百完美的程序.程序总难免存在各式各样的问题.所以,程序中添加对于错误的处理机制是十分有必要的.这就好比人多 ...

  6. SQL Server安全(5/11):架构与安全(Schemas and Security)

    在保密你的服务器和数据,防备当前复杂的攻击,SQL Server有你需要的一切.但在你能有效使用这些安全功能前,你需要理解你面对的威胁和一些基本的安全概念.这篇文章提供了基础,因此你可以对SQL Se ...

  7. 200、301、302、304、404等HTTP状态码

    在网站建设的实际应用中,容易出现很多小小的失误,就像mysql当初优化不到位,影响整体网站的浏览效果一样,其实,网站的常规http状态码的表现也是一样,Google无法验证网站几种解决办法,提及到由于 ...

  8. SQL - 内连接与外连接

    PDF下载地址:SQL-内连接与外连接.pdf 连接查询在关系型数据库中经常用到,是多表联合查询的基础. 主要包含:内连接,外连接,交叉连接. SQL - 内连接与外连接 内连接 等值连接 不等值连接 ...

  9. 图论 ---- spfa + 链式向前星 ---- poj 3268 : Silver Cow Party

    Silver Cow Party Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 12674   Accepted: 5651 ...

  10. 【转】 Key/Value之王Memcached初探:二、Memcached在.Net中的基本操作

    一.Memcached ClientLib For .Net 首先,不得不说,许多语言都实现了连接Memcached的客户端,其中以Perl.PHP为主. 仅仅memcached网站上列出的语言就有: ...