sharepoint 修改AD密码
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密码的更多相关文章
- 在泛微系统中修改AD密码的配置
参照文档: Windows server 2008 R2 安装AD域证书:https://blog.csdn.net/zhuyongru/article/details/81107839 配置泛微OA ...
- Python 修改AD密码
前提条件: AD 已开启证书服务(最重要的一句话). import ldap3 SERVER = 'adserver' BASEDN = "DC=example,DC=com" U ...
- 烦烦烦SharePoint2013 以其他用户登录和修改AD域用户密码
sharepoint默认是没有修改AD密码 和切换 用户的功能,这里我用future的方式来实现. 部署wsp前: 部署后 点击以其他用户身份登录 点击修改用户密码: 这里的扩展才菜单我们用Custo ...
- SharePoint2013 以其他用户登录和修改AD域用户密码 功能
sharepoint默认是没有修改AD密码 和切换 用户的功能,这里我用future的方式来实现. 部署wsp前: 部署后: 点击以其他用户身份登录 点击修改用户密码: 这里的扩展才菜单我们用Cust ...
- SharePoint中修改密码的WEB Part之终极版:即可以修改AD,又可以修改本机用户密码的Web Part!!
转:http://www.cnblogs.com/dosboy/archive/2007/08/01/838859.html 在网上查了那么多SharePoint密码修改的第三方开发,都有问题.总结下 ...
- sharepoint修改密码
增加SharePoint2010修改域密码功能 前提SharePoint2010的用户基于AD的,因此修改密码是修改了AD的密码,当然也可以修改本机密码(非域的密码).这里我们讨论修改域密码.我们修改 ...
- java修改AD域用户密码使用SSL连接方式
正常情况下,JAVA修改AD域用户属性,只能修改一些普通属性, 如果要修改AD域用户密码和userAccountControl属性就得使用SSL连接的方式修改, SSL连接的方式需要操作以下步骤: 1 ...
- C#修改AD账号及密码
在使用AD域环境搭建的账号系统修改密码的时候比较麻烦一般需要管理员在域环境去进行对用户的密码进行修改. 以下就是用来查询和修改AD域密码的方法. 1 /// <summary> 2 /// ...
- 增加SharePoint2010修改域密码功能
转:http://blog.163.com/hr_test/blog/static/16485210720137953131694/ 前提 SharePoint2010的用户基于AD的,因此修改密码是 ...
随机推荐
- Web 前端开发精华文章推荐(HTML5、CSS3、jQuery)【系列二十三】
<Web 前端开发精华文章推荐>2014年第2期(总第23期)和大家见面了.梦想天空博客关注 前端开发 技术,分享各类能够提升网站用户体验的优秀 jQuery 插件,展示前沿的 HTML5 ...
- 【大数据】Linux下安装Hadoop(2.7.1)详解及WordCount运行
一.引言 在完成了Storm的环境配置之后,想着鼓捣一下Hadoop的安装,网上面的教程好多,但是没有一个特别切合的,所以在安装的过程中还是遇到了很多的麻烦,并且最后不断的查阅资料,终于解决了问题,感 ...
- WPF依赖属性详解
WPF依赖属性详解 WPF 依赖属性 英文译为 Dependency Properties,是WPF引入的一种新类型的属性,在WPF中有着极为广泛的应用,在WPF中对于WPF Dependency P ...
- 第22/24周 等待和I/O延迟统计
大家好,欢迎回到性能调优培训的第22周.上周我谈了SQL Server里的基线,今天我们继续,谈下SQL Server里的等待和I/O延迟统计.当我进行SQL服务器健康检查时,我总会使用这2个维度全局 ...
- postgres中的中文分词zhparser
postgres中的中文分词zhparser postgres中的中文分词方法 基本查了下网络,postgres的中文分词大概有两种方法: Bamboo zhparser 其中的Bamboo安装和使用 ...
- Git学习笔记(二)
一.创建远程仓库(GitHub) 1.GitHub网站地址:https://github.com/,这个网站就是提供Git仓库托管服务的,所以,只要注册一个GitHub账号,就可以免费获得Git远程仓 ...
- Swift的期待
去年底苹果开源 Swift 之后,Google.Facebook和Uber三个互联网巨头就曾在伦敦召开会议讨论Swift在各自开发战略中的地位.近日业界有消息传出,谷歌有意考虑将Swift作为Andr ...
- 你应该知道的 RPC 原理
作者:伯乐在线 - meituanalibaba 网址:http://blog.jobbole.com/92290/ 在校期间大家都写过不少程序,比如写个hello world服务类,然后本地调用 ...
- 关于js性能
1,声明变量要赋初值2,尽量避免声明全局变量,可以减少与系统的重名3,当编写大量js代码时,难免会遇到命名冲突,这是可以通过模拟命名空间方式 来避免冲突4,尽量避免使用全局变量,搜索全局变量是 ...
- R语言介绍
R语言简介 R语言是一种为统计计算和图形显示而设计的语言环境,是贝尔实验室(Bell Laboratories)的Rick Becker.John Chambers和Allan Wilks开发的S语言 ...