sharepoint2010 删除失去AD账号的用户方法,代码方法

Exchange Online - Assign Account Recover Deleted Items权限 最近有收到user request,要recover在outlook online中删除的邮件。但是在打算使用时发现,Office365 admin account无法点击 'Recover deleted items',提示 ' You do not have permission to edit this information.' 本文对如何设置权限做介绍。 阅读详情

Delete Orphaned AD Users from the Site Collection


Recently I was working on the packaging up the site collection developed in my virtual machine and deploying to the client’s environment. In my virtual environment, I have created small sampling of client users in my active directory (e.g. Niks\tpatel) during the development and demo process. During the deployment, when I packaged up the site collection using the Backup-SPSite command and restored in the client environment using the Restore-SPSite command, everything looked great except people picker controls and security management pages showed the source active directory users (e.g. Niks\tpatel). What it means is there are duplicate users from my active directory and client’s active directory causing confusion among user identity (e.g. Niks\tpatel and ClientAD\tpatel). This is really interesting because as I am researching this issue, this has been known issue since WSS 2.0 era (see the links below) and I have never came across this situation in last 5 years. May be I have never noticed enough.

In my sample use case, I have a “Niks\tpatel” user added to the site membership in my virtual environment. After deploying the site collection in the client environment, I am able to browse the “Niks\tpatel” user from the target environment’s people picker control.

To gain more insight into where would people picker control show the user information from, I have launched extensive research on web and gladly found many resources but none of them captured in one article. This article summarizes what I have learned over the last couple of days and how to clean up the orphaned AD users from the site collection or cleanup the users from the site collection before getting ready for the packaging up for the deployment.

As we all know, SharePoint Foundation or WSS provides wonderful Active Directory integration from out of the box but many of us don’t know, behind the screen, WSS acquire user’s login name, display name, and email address whenever they are added to the site membership and saves them to the UserInfo table in the content database of the given site collection\web application. Whenever user creates or modifies the SharePoint list items, these users will linked to the list item and shows up in the “Created By” and “Modified By” indicators.

What it means is People Picker will show the combined users view from the authentication provider source (e.g. LDAP accounts from the Windows Authentication/Active Directory) and the accounts from the User Information List (UserInfo table in WSS_Content DB of the Site Collection/web application). This is important to understand as it means that accounts that may have been deleted or disabled or not exists in your authentication provider still show up because he may exists in the User Information List. In our scenario, this is where orphaned AD user (Niks\tpatel) shows up in the people picker control because even though she is not available in the target environment’s active directory but lingered in the UserInfo table from the source site collection.

To view the User Information List from the browser, log in to the site using the Administrator privileges, and navigate to the /_catalogs/users/simple.aspx. This page will show all the active users from the User Information List. Please note that you can’t delete the users from User Information List using the browser interface.

Additionally, you can browse the full User Information List by accessing the UserInfo table from the site collection\web application content database. As you can see from the folllowing screen, only three users are marked as active. Please note that you should not make any direct modification to the database or delete users from the UserInfo table. As you can see from the following screen, Niks\tpatel is still active user and exists in the UserInfo table even though she is either deleted from the active directory or not exists in the target active directory.

Now, since we know UserInfo table is culprit to show the user in the people picker, how would you clean up the orphaned AD users from the User Information List?

The best approach to delete the orphaned AD users from the User Information List, you should write a custom code and remove the user using the SPWeb.SiteUsers API. This will delete the users from the top level site collection. If you are inheriting the site membership in the sub sites, deleting users from the top level site will delete the users from the sub site making sure deleted users are not available in the sub site’s people picker. If you have broken the site membership inheritance, you have to manually write a extra code to delete the users using the SPWeb.Users API.

Step 1: To delete the specific user, Open the Visual Studio 2010 and create the Console Application, Target the project to Microsoft.NET 3.5 framework and “Any CPU” build. Please be careful with this step because Visual Studio 2010 defaults to Microsoft.NET Framework 4.0 and 32-bit runtime. Reference the Microsoft.SharePoint.dll in the console application, Import the Microsoft.SharePoint.dll in the class, and copy the following code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;

namespace DeleteSPUserInfoListUser
{
    class Program
    {
        static void Main(string[] args)
        {

            string loginName = @”Niks\tpatel”;  //@”Niks\Administrator“
            using (SPSite spSite = new SPSite(“http://sp2010vm“))
            {
                using (SPWeb spWeb = spSite.OpenWeb())
                {
                    SPUser spUser = spWeb.SiteUsers[loginName];
                    if (!spUser.IsDomainGroup &&
                        !spUser.IsSiteAdmin &&
                        !loginName.Equals(@”NT AUTHORITY\authenticated users”) &&
                        !loginName.Equals(@”NT AUTHORITY\LOCAL SERVICE”) &&
                        !loginName.Equals(@”SHAREPOINT\system”))
                    {
                        spWeb.SiteUsers.Remove(spUser.LoginName);
                        spWeb.Update();

                        Console.WriteLine(“User Deleted – ” + loginName);
                    }
                }
            }

            Console.WriteLine(“Press any key…”);
            Console.Read();
        }
    }
}

Step 2: Modify the code by replacing your Site URL and User Name. You can extend this code to delete all the orphaned users by looping through the collection.

Step 3: Run the console Application and verify that User is deleted and program runs successfully.

Step 4: Access the UserInfo table from the site collection\web application content database and verify that user is flagged as deleted and she is no longer active. Alternatively, you can access the /_catalogs/users/simple.aspx to verify that user isn’t exists in the User Information List.

Step 5: Verify that deleted user (e.g. Niks\tpatel) is not browsable in the People Picker control.

That’s it. Hopefully this will be helpful to someone who is looking for both background story and sample code to clean up the site collection users.

【NTN 卫星通信】使用地面网络和卫星网络接入的终端应用场景 卫星接入有广覆盖的特点, 可以改善地面接入网覆盖或无线条件差的地区(例如多径干扰)的服务可用性。对于高速移动中需要实时业务的终端,如IMS语音/视频会议,可以通过地面接入和卫星接入同时实现与5G系统的双连接,在地面接入网不可用的情况下获得连续可靠的业务。 阅读详情

相关推荐

Telegram如何删除账号?

进入设置→隐私和安全→Advanced, 选择第一项删除所有聊天记录,把第二项设置为一个月,等待一个月后就可以删除账号。 Q: How do I delete my account? If you would like to delete your account, you can do this on the deactivation page. Deleting your a...

Make 4万+

薄膜比拟、开口截面扭转承载力以及风电混塔水平缝张开状态下抗扭承载力推导

风电混塔水平缝张开状态下的抗扭承载力推导,从弹性力学说起

George的博客 873

How to restore deleted user accounts and their group memberships in Active Directory

How to restore deleted user accounts and their group memberships in Active DirectoryView products that this article applies to.function loadTOCNode(){} Article ID

afterain的专栏 3192

硬件基础(4):(6)高精度ADC设计中模拟地与数字地的划分与连接

在实际 PCB 设计中,**接地与布线**对于获得干净的参考电压和高精度 ADC 测量至关重要。下面详细阐述**如何在硬件层面减少数字噪声耦合到模拟电路、保障参考电压的稳定性**。

FCZlll的博客 2645

程序员必备75道逻辑思维题(附答案)之二

逻辑训练 身为一个大数据工程师,平时的算法训练还是不能少的,今天给大家看几道我曾经看到的逻辑思维题觉得很好,想分享一下。 【6】一个球、一把长度大约是球的直径2/3长度的直尺.你怎样测出球的半径?方法很多,看看谁的比较巧妙 【7】五个大小相同的一元人民币硬币。要求两两相接触,应该怎么摆? 【8】猜牌问题 S先生、P先生、Q先生他们知道桌子的抽屉里有16张扑克牌:红桃A、Q、4 黑桃J、8、4、2、...

蛋蛋淡淡定的庄园 3547

简单登录,无权限

核心是利用com.google.common.cache.LoadingCache 实现定时map,把token作为key,登录名作为value,存入定时map。 controller: package com.zjzy.controller; import com.zjzy.po.postgres.Account; import com.zjzy.response.BaseResponse; import com.zjzy.service.AccountService; import com.z.

yaoct的博客 372

17、高通8155座舱平台--QNX开发基础

我个人习惯,拿到一个新板子,第一件事就是打开IDE,建一个空的QNX项目,然后跑一遍Hello World。比如,当触摸屏被按下时,驱动发一个脉冲给UI进程,告诉它“嘿,有人摸屏幕了”。我在8155上调试时,就遇到过因为脉冲优先级太低,导致触摸响应延迟的问题。IDE自带的编译器是qcc,它其实是gcc的封装。QNX的IPC机制,可以说是它最牛的地方。嗯,这套流程走下来,你对QNX开发的基本功就差不多了。QNX默认的消息缓冲区大小是64KB,如果你要传大块数据,比如音频流,那就得用共享内存了。

woailuojp的博客 51

wordpress忘记账户_如何允许用户删除其WordPress帐户

wordpress忘记账户Do you want to allow users to delete their own WordPress accounts? If you allow user registration on your WordPress site, and a user does not want to keep their account anymore, then they...

cumohuo9136的博客 682

MCP+A2A:从实验室到生产环境的落地之旅

本文通过实际项目中的落地案例,展示了 MCP+A2A 协议结合使用的强大功能和广泛适用性。同时,我们也探讨了开发者社区的贡献、与其他技术的融合,以及未来技术趋势的展望。希望本文能够帮助读者更好地理解如何将这一架构从实验室推向生产环境,推动 AI 技术的实际应用。

加入“Super Entity”,与全能开发团队共探AI智能体与数字人项目,开启前沿技术之旅。 1494

Agentic AI为教育行业赋能,提示工程架构师解析应用潜力

然而,即便是最先进的 LLMs,在面对复杂、动态、需要持续规划和调整的教育场景时,也常常显得力不从心,它们更像是强大的“问答机器”,而非真正意义上的“学习伙伴”或“教学助手”。在教育场景中,传统的 AI 工具可能只能回答学生提出的特定问题,或者根据预设的规则推送一些学习材料。无论您是教育技术领域的开发者、产品经理,还是一线的教育工作者、教育管理者,抑或是对 AI 教育应用充满好奇的研究者,本文都将为您提供宝贵的 insights,助您把握 Agentic AI 时代教育创新的脉搏。

架构师的AI之路,分享AI应用开发架构的学习与实践。 466

删除用户时报错

当删除用户时报错,普通用户要么在线删不掉,要么还有进程存在 userdel: user wangyuan is currently used by process 18121 who 查看是否在线,若存在,踢掉 pkill -kill -t pts/0 若不存在则,查看进程 ps -ef | grep18121 最后确认是否能删除 kill -918121 ...

qq_36270681的博客 491

AUTOSAR知识点:PDUR(PDU Router)基础知识

通过定义路由表和实现相应的路由和缓冲逻辑,PDUR能够确保PDU在不同ECU之间的可靠传输。在上述示例中,我们定义了一个简单的PDUR路由表,其中列出了源ECU和目标ECU之间的映射关系。当收到来自源ECU的PDU时,PDUR模块会根据路由表查找目标ECU,并将PDU传输到相应的目标ECU。PDUR的主要功能是将接收到的PDU从一个ECU路由到另一个ECU,并确保数据的正确传输。需要注意的是,上述示例是一个简化的实现,实际的PDUR模块可能包含更复杂的功能和逻辑。

EcmFsharp的博客 1157

chatGPT提示:You do not have an account because it has been deleted or deactivated 怎么办?

最近有很多网友反映在登录chatGPT时遇到了报错:Oops!You do not have an account because it has been deleted or deactivated 如下图所示根据笔者的经验出现这个问题基本可以认定是两个方面的问题一种可能性就是账号被封掉了。

chat8889的博客 4312

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

如何解决登录遇到Oops!Account deactivated错误

如何解决登录遇到Oops!Account deactivated错误

wrangler_csdn的博客 1万+

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

JDBC(一)

今日内容 1. JDBC基本概念 2. 快速入门 3. 对JDBC中各个接口和类详解 JDBC: 1. 概念:Java DataBase Connectivity Java 数据库连接, Java语言操作数据库 * JDBC本质:其实是官方(sun公司)定义的一套操作所有关系型数据库的规则,即接口。各个数据库厂商去实现这套接口,提供数据库驱动jar包。我们可以使用这套接口(JDBC)编程,真正执行的代码是驱动jar包中的实现类。 2. 快速入门: * 步骤: 1. 导入驱动jar包 mysql

weixin_47366250的博客 162

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

Kubernetes系列~Master节点安装

Master安装 gary@172.36.13.5’s password: ​ ┌────────────────────────────────────────────────────────────────────┐ ​ │ • MobaXterm 10.9 • │ ​ │ ...

haha0308的专栏 2376

6-5 设计银行Account类

题目:定义一个Account类,表示银行账户。注意,Account类的定义应该这样开始:也就是说,Account类的class前面不要有public。。裁判测试程序样例:in.close();//设计银行Account类//TODO 编写代码。

m0_63722201的博客 1624

第10关:删除表中的记录delete(二)

插入语句

m0_64562382的博客 540

windows 帐户 入侵_如何在Windows 7、8或10中删除用户帐户

windows 帐户 入侵If you have a bunch of user accounts on your Windows PC that youdon’t need anymore, it may be time to clean them out. Today we’ll take a look at how to delete a user account in Windows. ...

culinxia2707的博客 880

WMI002-WMI学习笔记(二)——Win32_Account类

原文链接: http://msdn.microsoft.com/en-us/library/aa394061(v=vs.85).aspx 测试代码: http://blog.youkuaiyun.com/eyuanatqqdotcom/article/details/7462720 Applies to: desktop apps only 应用于:桌面应用程序 The

易元——美好吧 1150

AD账户误删了怎么办?这几种图文办法让你不用提桶跑路!

两种便捷方法带你快速恢复误删的AD账户,IT系统管理员再也不用担心提桶跑路啦

qq_42465243的博客 4329

SharePoint 2010中如何彻底删除用户

以前我们在SharePoint 2007 中想要把一个用户从网站集中彻底删除的话,可以通过选择Site Actions—Site Settings—User and Permission—All people……   以前我们在SharePoint 2007 中想要把一个用户从网站集中彻底删除的话,可以通过选择Site Actions—Site Settings—User and

yl_99的专栏 1637

查找并恢复已删除的 AD 对象

ADRecycleBin overall.ca 以往任何时候都被移动快速而管理或清理向上 Active Directory (AD) 域,并删除不应具有的东西吗? 或者,也许您担心一个新的 staffer 就得到了能够从目录中删除对象。 简单来说:错误甚至与所有这些确认对话框会发生。 Windows Server 2008 R2 添加自己的 Active Direct...

weixin_33995481的博客 717

如何查看AD域账号的删除记录

**如何查看AD域账号删除记录及恢复** 在日常AD域管理中,有时候我们不小心删除了域账号,或者我们想查看这个域账号是什么时候创建并删除的,那怎么办?是否可以恢复?其实微软本身已经为我们的账号信息做了备份机制,活动目录对象如果被删除,系统并没有直接将其彻底删除,而是放在了一个不可见的 CN 中,这个 CN就是 Delete Objects 。被删除的账户会在里面待保存180 天(默认)。 查看域账

灰-灰的博客 1万+
上一篇: WIN2008 R2修改密码策略
下一篇: configuration information could not be read from the domain controller报错
*道童*
博客等级 码龄19年 29粉丝 107原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值