Ssis 使用SSI填充Active Directory
我已经看到了大量从广告中提取数据的帖子,但我需要更新广告,却找不到我要找的内容。我的公司一直在使用第三方供应商(intelli desk)为部门、经理和电话etx提供服务。多年的信息。AD只是用来创建用户名和分配域访问权限。我们知道需要使用intelli desk内的信息更新AD。我已经建立了一个查询,比较AD和intelli desk数据库,并希望在sn和givenName匹配并更新Ext.,Dept。,在广告中,我认为SSIS软件包可能是实现这一点的最佳方式,这样它就可以成为一项预定的工作,因为我认为我们不会停止使用第三方软件。有没有人对如何使用SSIS来实现这一点有任何建议?如果有,您将如何进行。如果没有,还可以使用什么 我最近刚刚不得不从数据库中完成类似的任务(插入、更新)Active Directory用户。您可以完成此任务的选项很少:Ssis 使用SSI填充Active Directory,ssis,active-directory,Ssis,Active Directory,我已经看到了大量从广告中提取数据的帖子,但我需要更新广告,却找不到我要找的内容。我的公司一直在使用第三方供应商(intelli desk)为部门、经理和电话etx提供服务。多年的信息。AD只是用来创建用户名和分配域访问权限。我们知道需要使用intelli desk内的信息更新AD。我已经建立了一个查询,比较AD和intelli desk数据库,并希望在sn和givenName匹配并更新Ext.,Dept。,在广告中,我认为SSIS软件包可能是实现这一点的最佳方式,这样它就可以成为一项预定的工作,
SSIS
包完成此任务。此technet解释如何使用外部源将用户导入Active DirectorySSIS
包将使用在VBA
或C#
中编写的外部脚本。本文中提供的C#
示例是在较旧的.NET
库中编写的。它使用的是DirectoryEntry
类。使用这个类没有什么错,但是,在.NET3.5
及更高版本中,Microsoft引入了System.DirectoryServices.AccountManagement
,使用起来更简单AccountManagement
名称空间自己编写。听起来并不难存储过程
,该过程将返回用户信息
这里有一些东西让你开始
通过调用存储过程
从数据库加载用户信息
public static DataTable GetUserInfoByUsername(string username)
{
//call stor proc to return data
//return datatable or custom class that will hold user iformation
}
编写两种方法,分别创建
和更新
用户。使用datatable
中的值填充Active Directory中的用户属性
public static string CreateUser(DataTable dt, string password)
{
//CREATE CONNECTION TO ACTIVE DIRECTORY
using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "yourdomain.com"))
{
//CREATE A NEW USERPRINCIPAL OBJECT
using (UserPrincipal principal = new UserPrincipal(ctx))
{
//TODO: you need to populate the below info with values from dt
principal.Enabled = true; //IF NOT ENABLED YOU CAN'T AUTHENTICATE THE USER
principal.UserPrincipalName = username;
principal.Name = "name";
principal.DisplayName = "firstname lastname";
principal.EmailAddress = "email@test.com";
principal.VoiceTelephoneNumber = "12345678910";
principal.GivenName = "firstname";
principal.Surname = "lastname";
principal.SetPassword(password);
try
{
principal.Save();
}
catch(Exception ex)
{
throw;
}
}
}
}
您可以采取类似的方法来更新用户
public static void UpdateUser(string userName, DataTable dt)
{
using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "yourdomain.com"))
{
//you have more than one way to search for a user in AD. Identitype has more choises
using (UserPrincipal principal = UserPrincipal.FindByIdentity(ctx, Identitype.samAccountName, username))
{
if (principal !== null)
//update user properties with data from datatable dt
...
principal.Save();
}
}
}
要记住的东西。默认情况下,UserPrincipal
类不会显示每个active directory属性。获取这些属性的最快方法是使用DirectoryEntry
class。您可以调用getUnderlineObject()
方法的principal
DirectoryEntry de = (principal.GetUnderlyingObject() as DirectoryEntry);
if (de != null)
{
if (de.Properties.Contains("company"))
string company = de.Properties["company"][0].ToString();
}
如果要运行某种作业来执行这些操作,只需让存储过程
返回所有用户,并在调用这些方法之前使用foreach
循环即可
我建议您编写一个windows服务并在那里执行所有这些操作
*注意代码不完整。根据您的需要,您需要修改代码。**我最近刚刚从数据库中完成了一项类似的任务(插入、更新)Active Directory用户。您可以完成此任务的选项很少:
SSIS
包完成此任务。此technet解释如何使用外部源将用户导入Active DirectorySSIS
包将使用在VBA
或C#
中编写的外部脚本。本文中提供的C#
示例是在较旧的.NET
库中编写的。它使用的是DirectoryEntry
类。使用这个类没有什么错,但是,在.NET3.5
及更高版本中,Microsoft引入了System.DirectoryServices.AccountManagement
,使用起来更简单AccountManagement
名称空间自己编写。听起来并不难存储过程
,该过程将返回用户信息
这里有一些东西让你开始
通过调用存储过程
从数据库加载用户信息
public static DataTable GetUserInfoByUsername(string username)
{
//call stor proc to return data
//return datatable or custom class that will hold user iformation
}
编写两种方法,分别创建
和更新
用户。使用datatable
中的值填充Active Directory中的用户属性
public static string CreateUser(DataTable dt, string password)
{
//CREATE CONNECTION TO ACTIVE DIRECTORY
using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "yourdomain.com"))
{
//CREATE A NEW USERPRINCIPAL OBJECT
using (UserPrincipal principal = new UserPrincipal(ctx))
{
//TODO: you need to populate the below info with values from dt
principal.Enabled = true; //IF NOT ENABLED YOU CAN'T AUTHENTICATE THE USER
principal.UserPrincipalName = username;
principal.Name = "name";
principal.DisplayName = "firstname lastname";
principal.EmailAddress = "email@test.com";
principal.VoiceTelephoneNumber = "12345678910";
principal.GivenName = "firstname";
principal.Surname = "lastname";
principal.SetPassword(password);
try
{
principal.Save();
}
catch(Exception ex)
{
throw;
}
}
}
}
您可以采取类似的方法来更新用户
public static void UpdateUser(string userName, DataTable dt)
{
using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "yourdomain.com"))
{
//you have more than one way to search for a user in AD. Identitype has more choises
using (UserPrincipal principal = UserPrincipal.FindByIdentity(ctx, Identitype.samAccountName, username))
{
if (principal !== null)
//update user properties with data from datatable dt
...
principal.Save();
}
}
}
要记住的东西。默认情况下,UserPrincipal
类不会显示每个active directory属性。获取这些属性的最快方法是使用DirectoryEntry
class。您可以调用getUnderlineObject()
方法的principal
DirectoryEntry de = (principal.GetUnderlyingObject() as DirectoryEntry);
if (de != null)
{
if (de.Properties.Contains("company"))
string company = de.Properties["company"][0].ToString();
}
如果要运行某种作业来执行这些操作,只需让存储过程
返回所有用户,并在调用这些方法之前使用foreach
循环即可
我建议您编写一个windows服务并在那里执行所有这些操作
*注意代码不完整。根据您的需要,您需要修改代码。**可能有第三方组件,我会先检查CozyRoc,否则您会将.NET脚本作为目标。您感兴趣的方法位于
System.DirectoryServices
库中。这就是说,能够完成这一壮举的帐户将在你的环境中拥有上帝般的力量,所以要小心,可能是第三个pa