简体   繁体   English

使用SQL Server修改Active Directory

[英]Active Directory modifications using SQL Server

I've exported my AD into CSV and pumped it into SQL, the goal is to modify some fields and import it back into AD. 我已经将我的AD导出为CSV并将其泵送到SQL中,目的是修改某些字段并将其重新导入AD。

I've done every field I need to do except one, the proxyAddress field. 除了一个proxyAddress字段外,我已经完成了所有需要做的工作。

My data looks like this: 我的数据如下所示:

proxyAddresses
sip:john.smiths@email.com;SMTP:john.smith@email.com
sip:james.jones@email.com;SMTP:james.jones@email.com;notes:james.jones/EMAIL/

etc... 等等...

I'm trying to change the sip: values, but as they're all different username, and have SMTP included, I'm struggling with the SQL LIKE command. 我正在尝试更改sip:值,但是由于它们都是不同的用户名,并且包含SMTP,因此我正在努力使用SQL LIKE命令。

I need to data to look like this: 我需要数据看起来像这样:

proxyAddresses
sip:john.smiths@newemail.com;SMTP:john.smith@email.com
sip:james.jones@newemail.com;SMTP:james.jones@email.com;notes:james.jones/EMAIL/

Changing the sip: value, but leaving the rest as they are. 更改sip:值,但其余部分保持不变。

Any help would be appreciated. 任何帮助,将不胜感激。

We don't know the tables definition nor the mapping between new and old values, so just for the start something like this: 我们不知道表的定义,也不知道新值和旧值之间的映射,因此一开始,就像这样:

declare @e varchar(1000) = 'sip:james.jones@email.com;SMTP:james.jones@email.com;notes:james.jones/EMAIL/'
declare @newEmail varchar(126) = 'james.jones@newemail.com'

select stuff(@e, charindex(':', @e)+1, charindex(';', @e)-charindex(':', @e)-1, @newEmail)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM