Changes of user relationship in AD can't be correctly synchronized to SCSM
The relationship of users might be not correctly updated if related users were once re-named in AD or have duplicate records in DB.
Cause 1 - Known Issue: a renamed user in AD will be treated as a new object in SCSM
Symptom
There are multiple records for the same user in BaseManagedEntity.
Analysis
There is a blog talking about this kind of behavior: https://blogs.technet.microsoft.com/manageabilityguys/2013/06/17/managing-username-changes-in-service-manager/
I did a test in my lab environment (SCSM 2012 R2). After I rename a user in AD and run AD connector, there will be two objects co-existing in the table [dbo].[ManagedEntity] for the user, and two relationships in the table [dbo].[Relationship].
For example, after I change my user name from "wendi" to "wendii", then to "wendie", there are 3 user objects and 3 relationships in the DB.
Relationship:
BaseManagedEntity:
Then I manually deleted "wendi" from DB, and changed the manager from "weiwen" to "Administrator" in AD. The relationship got updated for the newest object "wendie", but not for the old object "wendii". That resulted in two managers for the user "wendii"/"wendie", which is actually the same user in AD.
Resolution
Firstly remove the duplicated users from [dbo].[ManagedEntity].
If you don’t want to lose the relationships associated with the old object, please use the script in the blog to move all relationships from old object to new object.
Note: In the script there is a path pointing to SCSM PowerShell Module. You may need to alter it manually based on the real location.
Remove the duplicate user object:
$oldADUser = "wendi"
Get-SCClassInstance -Class (Get-SCClass -Name "System.Domain.User") -Filter "UserName -eq $oldADUser | Remove-SCClassInstance
After confirming there is no duplicate user objects, please change the manager relationship in AD, then check if the relationship can be updated correctly by AD connector.
Cause 2 - Duplicate AD connector introduces duplicate user records
If there is only 1 record in BaseManagedEntity, but multiple records in [LFXSTG].[AD_User], it is probably from duplicate AD connectors.
We can check the data sources of the records in [LFXSTG].[AD_User]:
This query can give you information about all data sources (connectors):
Select * from LFX.Datasource
A sample output:
DataSourceId | DataSourceName | DataSourceAddress | DisplayName |
---|---|---|---|
2 | ADConnector.af492f92b2d04b4092d2f0c6108a4aff | LDAP://DC=contoso,DC=com | CONTOSO AD Connector |
11 | ADConnector.762fe647adc14c2daba1191291e6b37f | LDAP://OU=AdminUsers,OU=Users,DC=contoso,DC=com | CONTOSO AD Connector - Users |
12 | ADConnector.b93d4f78d799462280e841e228f5f921 | LDAP://DC=contoso,DC=com | CONTOSO AD Connector - Printers |
13 | ADConnector.d49f58ebf7b84c509c3426cde55c7cd5 | LDAP://DC=contoso,DC=com | CONTOSO AD Connector - Computers |
14 | ADConnector.e56e3f09b5614c5ea554e3d0c06c7da4 | LDAP://DC=contoso,DC=com | CONTOSO AD Connector - Groups |
15 | ADConnector.747d1f1f252f46a59634378686a32dbe | LDAP://OU=SCSM,OU=Groups,DC=contoso,DC=com | CONTOSO AD Connector - SCSM Groups |
Resolution
Disable all duplicate connectors. After that, all users modified in the future could be correctly updated.
For those users which are already affected by the issue, we can follow below steps to process them.
- Run this query in ServiceManager to get the users who have duplicate relationships with relationship isDeleted = 0, as well as the connectors that brought the relationships.
(This query focuses on "manager" relationship)
Select distinct
u.DisplayName 'User Display Name',
u.UserName_6AF77E23_669B_123F_B392_323C17097BBD 'User',
Manager.UserName_6AF77E23_669B_123F_B392_323C17097BBD 'Manager',
r.RelationshipId,
r.IsDeleted 'Is Relationship Deleted',
C.DisplayName 'Connector',
BME.IsDeleted 'Is Connector Deleted',
R.LastModified
from Relationship R
left join RelationshipType RT on R.RelationshipTypeId = RT.RelationshipTypeId
left join MT_System$Domain$User Manager on manager.BaseManagedEntityId = R.SourceEntityId
left join MT_System$Domain$User U on u.BaseManagedEntityId = r.TargetEntityId
inner join DiscoverySourceToRelationship DSTR on R.RelationshipId = DSTR.RelationshipId
Left join DiscoverySource DS on DS.DiscoverySourceId = DSTR.DiscoverySourceId
left join MT_Connector C on convert(nvarchar(256),DS.ConnectorId) = C.Id
Left join BaseManagedEntity BME on C.BaseManagedEntityId = BME.BaseManagedEntityId
where RelationshipTypeName like '%System.UserManagesUser%' and u.BaseManagedEntityId in
(
Select
u.BaseManagedEntityId
from Relationship R
left join RelationshipType RT on R.RelationshipTypeId = RT.RelationshipTypeId
left join MT_System$Domain$User Manager on manager.BaseManagedEntityId = R.SourceEntityId
left join MT_System$Domain$User U on u.BaseManagedEntityId = r.TargetEntityId
where RelationshipTypeName like '%System.UserManagesUser%' and r.IsDeleted = 0
group by U.UserName_6AF77E23_669B_123F_B392_323C17097BBD, u.BaseManagedEntityId
Having count(u.UserName_6AF77E23_669B_123F_B392_323C17097BBD) > 1)
order by U.UserName_6AF77E23_669B_123F_B392_323C17097BBD
- Use below steps to automate the removal of un-needed relationships whilst keeping the most current one.
- Copy the query result with headers and save as a .csv file.
- Remove the needed relationships from the .csv file.
- Use below PowerShell commands to remove the un-needed relationships.
# You may change the file path.
$listcsv = Import-Csv C:\Files\UnneededRelationships.csv
foreach($list in $listcsv)
{
Get-screlationshipinstance -id $listcsv.RelationshipId | remove-screlationshipinstance
}
Changes of user relationship in AD can't be correctly synchronized to SCSM的更多相关文章
- JMM(java内存模型)
What is a memory model, anyway? In multiprocessorsystems, processors generally have one or more laye ...
- 【翻译九】java-同步方法
Synchronized Methods The Java programming language provides two basic synchronization idioms: synchr ...
- Synchronized Methods
Synchronized Methods The Java programming language provides two basic synchronization idioms: synchr ...
- Java Interview Reference Guide--reference
Part 1 http://techmytalk.com/2014/01/24/java-interview-reference-guide-part-1/ Posted on January 24, ...
- Java Synchronization
Volatile Since Java 5 the volatile keyword guarantees more than just the reading from and writing to ...
- Java内存模型(JSR133)问与答
What is a memory model, anyway? In multiprocessor systems, processors generally have one or more lay ...
- Windows ->> FIX: “The security database on the server does not have a computer account for this workstation trust relationship”
前几天在做AlwaysOn实验时遇到搭建活动目录域时某台已经加入AD的机器无法以域管理员账户登录的情况. 报错信息是:The security database on the server does ...
- Sharepoint2013 AD组用户不同步
背景: SP2013列表库使用AD安全组授权访问,向AD安全组添加一个用户A,在Sharepoint AD同步(增量和完全)后,用户A仍然无法访问列表库:原因: 参考:安全令牌上的缓存 SP2013 ...
- freeradius整合AD域作anyconncet认证服务器
一.服务器要求 Radius服务器:centos6.6.hostname.selinux disabled.stop iptables AD域服务器:Windows Server 2008 R2 E ...
随机推荐
- day12 EL 表达式和国际化开发
day12 EL 表达式和国际化开发 1. EL(Expression Language) 表达式简介 1.1 执行运算 1.2 获取web开发常用对象(el 中定义了11个隐式对象) 1.3 使用 ...
- C#学习(一):委托和事件
预备知识 在学习委托和事件之前,我们需要知道的是,很多程序都有一个共同的需求,即当一个特定的程序事件发生时,程序的其他部分可以得到该事件已经发生的通知. 而发布者/订阅者模式可以满足这种需求.简单来说 ...
- 构建基于Netty 的HTTP/HTTPS 应用程序
HTTP/HTTPS是最常见的协议套件之一,并且随着智能手机的成功,它的应用也日益广泛,因为对于任何公司来说,拥有一个可以被移动设备访问的网站几乎是必须的.这些协议也被用于其他方面.许多组织导出的用于 ...
- 二十六、Hadoop学习笔记————Hadoop Yarn的简介复习
1. 介绍 YARN(Yet Another Resource Negotiator)是一个通用的资源管理平台,可为各类计算框架提供资源的管理和调度. 之前有提到过,Yarn主要是为了减轻Hadoop ...
- 关于Linux虚拟化技术KVM的科普
虚拟化技术应用越来越广泛,虚拟化技术需求越来越强劲.KVM.XEN.Docker等比较热门,尤其是KVM技术越来越受欢迎. 基于此背景,了解一下KVM+QEMU就有点必要了. 从网上收集了一些资料进行 ...
- 《Systems Performance》阅读笔记及收获
本文共三部分: 笔记之前的废话是和书结缘的过程: Systems Performance笔记是正文,记录了读书笔记以及一些实践: 一些优化记录将之前做的一些优化归纳起来,同时也能反思做的如何,加入跟G ...
- windows下使用 Secure Shell Client工具操作linux常用命令
如果项目部署在linux系统上,而我们使用的是windows系统,那我们可以使用Secure Shell软件进行操作,那怎么使用它来操作tomcat呢? 1. cd /usr/share/apach ...
- Cookie防篡改机制
一.为什么Cookie需要防篡改 为什么要做Cookie防篡改,一个重要原因是 Cookie中存储有判断当前登陆用户会话信息(Session)的会话票据-SessionID和一些用户信息. 当发起一个 ...
- mysql按条件 导出sql
mysqldump还有一个参数,就是--where 指定条件,这样我们就可以对一张表里的某些符合条件的数据,进行备份,导出.sql文件了 mysqldump -u root -p DB_Name -- ...
- 1.2 lambda 表达式的语法
1.2 lambda 表达式的语法 还以上一节中的排序为例.我们传递代码来检查某个字符串的长度是否小于另一个字符串的长度,如下所示: Integer.compare(first.length(), s ...