简体   繁体   中英

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.

I've done every field I need to do except one, the proxyAddress field.

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.

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.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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