Deployment Server / Active Directory Synchronization
来源:互联网 发布:淘宝王府井百货靠谱么 编辑:程序博客网 时间:2024/06/01 13:56
Have you set up an Active Directory Organizational Unit structure? Do you want your Deployment Server to automatically match computer groups to that structure? This guide will help you set up Deployment Server Computer Groups to automatically synchronize to your Active Directory Organizational Units.
First, you will need to verify that all the appropriate credentials are found in your Domain Accounts List. Go to Tools > Options > Domain Accounts. Click the Add button and fill out the information of the Domain Account for each of your Domains. This account should have permissions to query Active Directory to determine Organizational Unit membership. It is also the account used for joining computers to the Domain, so it should have permissions to do a Domain Join.
Click to view.
Second, you will need to have either the AClient or DAgent (for Vista) installed on all of your computers. AClient reports Organizational Unit membership to Deployment Server. If you are importing computers from a .csv or .xls file, make sure to include domain and Organizational Unit information in the import file.
Third, run the following SQL Query against your Deployment Server database.
- Copy everything between "--------Start Here--------" and "--------End Here--------"
--------Start Here--------IF EXISTS (SELECT * FROM sysobjects WHERE name='ou2group' AND xtype='TR')DROP TRIGGER ou2groupGOCREATE TRIGGER ou2group ON computer AFTER UPDATE ASIF (UPDATE(msnet_domain_ou) OR UPDATE(msnet_dns_domain))BEGINDECLARE @Done bitDECLARE @Left intDECLARE @Right intDECLARE @GroupName varchar(64)DECLARE @DomainOrganizational Unit varchar(256)DECLARE @ParentID intDECLARE @GroupID intSELECT @Done = 0, @Left = 0, @Right = 0SELECT @GroupName = msnet_dns_domain, @DomainOU = msnet_domain_ou FROM INSERTEDSELECT @ParentID = group_id FROM computer_group WHERE parent_id IS NULL AND name = @GroupNameIF @ParentID IS NULLBEGINEXEC ins_group @GroupName, @ParentIDSELECT @ParentID = group_id FROM computer_group WHERE parent_id IS NULL AND name = @GroupNameENDWHILE @Done = 0BEGINSET @Left = @Right + 1SET @Right = CHARINDEX('/', @DomainOU, @Left)IF @Right = 0BEGINSET @Right = LEN(@DomainOU) + 1SET @Done = 1ENDSET @GroupName = SUBSTRING(@DomainOU, @Left, @Right - @Left)SET @GroupID = NULLSELECT @GroupID = group_id FROM computer_group WHERE parent_id = @ParentID AND name = @GroupNameIF @GroupID IS NULLBEGINEXEC ins_group @GroupName, @ParentIDSELECT @ParentID = group_id FROM computer_group WHERE parent_id = @ParentID AND name = @GroupNameENDELSESET @ParentID = @GroupIDENDSELECT @GroupID = group_id FROM INSERTEDIF((SELECT COUNT(1) FROM computer WHERE group_id = @GroupID) < 2)DELETE FROM computer_group WHERE group_id = @GroupIDUPDATE computer SET group_id = @ParentID WHERE computer_id = (SELECT computer_id FROM INSERTED)ENDGO--------End Here--------
- Open SQL Query Analyzer
- For SQL 2000, open Start > All Programs > Microsoft SQL Server>Query Analyzer
- For SQL 2005, open Start > All Programs > Microsoft SQL Server 2005>SQL Server Management Studio and click on the "New Query" button
- In the Database Drop-down, select your Deployment Server Database (default is eXpress)
- Paste the SQL Query that you copied in step 1 into the Query Window
- Press the F5 key to execute the query
- Check the status message to verify that the query has executed completely
You have just added a SQL Trigger that will be run every time a computer record is updated. When it is run, it will add the computer to a Computer Group that matches its Active Directory Organizational Unit membership. You might want to force your computers to update so that the membership is updated immediately. To force an update, open the Deployment Server Console and select View > Reset Client Connections. When the computers connect back to Deployment Server, you will see that they are automatically added to a Computer Group structure that matches your Active Directory Organizational Unit.
The SQL Trigger
I will now explain, step-by-step, what the SQL Trigger does.
- We declare all of the variables we will use. Here is a brief description of each.
DECLARE @Done bitA true/false value that will be set to 1 (true) when all groups for the computer's Organizational Unit have been created
DECLARE @Left intThis is the character position where the current Organizational Unit we are looking at starts
DECLARE @Right intThis is the character position where the current Organizational Unit we are looking at ends
DECLARE @GroupName varchar(64)This is the name of the Organizational Unit we are looking at
DECLARE @DomainOU varchar(256)This is the entire Organizational Unit in the format Organizational Unit/Organizational Unit/Organizational Unit/...
DECLARE @ParentID intThis is the Computer Group number of the parent group of the computer or the Organizational Unit we are looking at
DECLARE @GroupID intThis is the Group number of the Organizational Unit we are looking at
- We determine if a Computer Group already exists for the Domain Name. If it does, we remember the group number.
SELECT @GroupName = msnet_dns_domain, @DomainOU = msnet_domain_ou FROM INSERTEDSELECT @ParentID = group_id FROM computer_group WHERE parent_id IS NULL AND name = @GroupName
- If the Domain Computer Group does not exist, we create one and remember the group number.
IF @ParentID IS NULLBEGINEXEC ins_group @GroupName, @ParentIDSELECT @ParentID = group_id FROM computer_group WHERE parent_id IS NULL AND name = @GroupNameEND
- For each Organizational Unit listed in DomainOU, we check to see if a group already exists. If it does, we remember the group number, otherwise we create one and remember the group number.
WHILE @Done = 0BEGIN
- Find the next Organizational Unit Name and remember it as DomainOU
SET @Left = @Right + 1SET @Right = CHARINDEX('/', @DomainOU, @Left)IF @Right = 0BEGINSET @Right = LEN(@DomainOU) + 1SET @Done = 1ENDSET @GroupName = SUBSTRING(@DomainOU, @Left, @Right - @Left)
- Determine if the Computer Group already exists.
SET @GroupID = NULLSELECT @GroupID = group_id FROM computer_group WHERE parent_id = @ParentID AND name = @GroupName
- If the group doesn't already exist, create one and remember the group ID.
IF @GroupID IS NULLBEGINEXEC ins_group @GroupName, @ParentIDSELECT @ParentID = group_id FROM computer_group WHERE parent_id = @ParentID AND name = @GroupNameEND
- If the group does already exist, remember the group ID
ELSESET @ParentID = @GroupIDEND
- Find the next Organizational Unit Name and remember it as DomainOU
- After we have created the entire Organizational Unit structure in Deployment Server, we check to see if the computer was the last one in the group, if it was, remove the group.
SELECT @GroupID = group_id FROM INSERTEDIF((SELECT COUNT(1) FROM computer WHERE group_id = @GroupID) < 2)DELETE FROM computer_group WHERE group_id = @GroupID
- Last, it adds the computer to the correct Organizational Unit Group in Deployment Server.
UPDATE computer SET group_id = @ParentID WHERE computer_id = (SELECT computer_id FROM INSERTED)
- Deployment Server / Active Directory Synchronization
- Windows server 2008 -- Active Directory
- SQL Server 查询 Active Directory
- Jasper Server Active Directory Integration
- 创建Windows 2000 Active Directory Server
- 创建Windows 2000 Active Directory Server
- Windows .NET Server 2003 Domains & Active Directory
- Windows .NET Server 2003 Domains & Active Directory
- MCTS Windows Server 2008 Active Directory Configuration
- Mastering Active Directory for Windows Server 2008
- windows server 2012 Active Directory 安装
- Active Directory
- Active Directory
- Active Directory
- Active Directory Cookbook for Windows Server 2003 and Windows 2000
- windows server 2003 Active Directory的安装(带ssl)
- Windows Server 2008 Active Directory 域服务新增功能
- MCTS Windows Server 2008 Active Directory Services Study Guide
- 日本地震为什么没有一间教室倒塌
- Java技术开源搜索引擎
- 比你手写代码更快的AJAX开发
- 阻止网页挂马的若干工具 - 信息安全专栏 -- 褚诚云 - CSDNBlog
- 开发者版本:你属于哪个版本的程序员?
- Deployment Server / Active Directory Synchronization
- JAVA程序员之路
- [客运中国]上线了
- 快进新房了
- Script to determine model
- 华为:做一家快乐公司
- 任正非:我的父亲母亲
- 任正非 天道酬勤
- 致新员工书