Skip to main content
avillanueva
23-Emerald II
Nov 20, 2026 2:00 PM UTC
Question

Changing user email addresses ... again

 Well, another company change and I am having to update user email addresses in Windchill. I pulled up my old post to remind myself how to do this.

Yep, change them in the LDAP but changes only are seen in Windchill when the users log in. That has a flaw since workflow emails and other communications will go to the old addresses in the mean time. Despite numerous articles, there does not seem to be a Windchill side sync task to update emails cached in the database. Is there? 

https://www.ptc.com/en/support/article/CS450948?source=search

https://support.ptc.com/help/windchill/r13.1.1.0/en/index.html#page/Windchill_Help_Center/participantadmin_chp/ParticipantAdminChp_UserSyncLDAP.html

I will share an awk script we wrote (AI and my co-op). We extracted the LDIF file, ran this script supplying a mapping file of old addresses to new addresses. In this most recent case, the email usernames had all changed so it was not just changing the organization.

#!/usr/bin/awk -f
# convert_emails.awk - convert LDIF "mail:" values using an old->new mapping file.
# Case-insensitive matching. Read-only on inputs. Warnings/summary go to stderr;
# the converted LDIF goes to stdout.
#
# Usage: awk -f convert_emails.awk mappings.txt sourceLdap.ldif > updated_extract.ldif
#
# mappings.txt format: one pair per line, old and new email separated by space(s) or tab(s)
# jdoe@oldname.com john.doe@newcompany.com

BEGIN {
BINMODE = 3 # avoid \n -> \r\n on Windows gawk; no effect on Linux/Mac or mawk
OLD = "oldname\\.com|reallyoldname\\.com"

# Read the mapping file directly here (rather than via NR==FNR) so an
# empty or missing mappings.txt can't cause the LDIF to be misread as
# mapping data
mapfile = ARGV[1]
delete ARGV[1] # so the main loop below only reads the LDIF
mapln = 0
while ((getline mline < mapfile) > 0) {
mapln++
sub(/\r$/, "", mline)
$0 = mline
if ($0 ~ /^[ \t]*#/ || NF < 2) continue # skip blank/comment/malformed lines
old = tolower($1)
if (old in map && map[old] != $2) dupmap[++n_dupmap] = old " (" map[old] " -> now " $2 ")"
map[old] = $2
n_map++
}
close(mapfile)
$0 = ""
}

# walk the LDIF, converting only well-formed "mail:" lines
{
line = $0
sub(/\r$/, "", line)
if (line ~ /^[Mm][Aa][Ii][Ll]:[ \t]/) {
val = line
sub(/^[Mm][Aa][Ii][Ll]:[ \t]*/, "", val)
sub(/[ \t]+$/, "", val)
key = tolower(val)
if (key in map) {
print "mail: " map[key]
converted++
next
}
if (key ~ OLD) {
unmatched[++n_unmatched] = "line " FNR ": " val
} else {
other[++n_other] = "line " FNR ": " val
}
}
print $0
}

END {
print "--- convert_emails.awk summary ---" > "/dev/stderr"
print "Mapping entries loaded: " n_map+0 > "/dev/stderr"
if (n_map == 0) print "WARNING: mappings.txt had no usable entries - nothing can be converted." > "/dev/stderr"
print "mail: lines converted: " converted+0 > "/dev/stderr"
print "" > "/dev/stderr"
print "Old domain (@oldname.com/@reallyoldname.com) addresses with NO mapping match (" n_unmatched+0 "):" > "/dev/stderr"
if (!n_unmatched) print " none" > "/dev/stderr"
for (i = 1; i <= n_unmatched; i++) print " " unmatched[i] > "/dev/stderr"
print "" > "/dev/stderr"
print "Other domains left unconverted, for awareness (" n_other+0 "):" > "/dev/stderr"
if (!n_other) print " none" > "/dev/stderr"
for (i = 1; i <= n_other; i++) print " " other[i] > "/dev/stderr"
if (n_dupmap) {
print "" > "/dev/stderr"
print "WARNING: duplicate old address keys in mappings.txt (last one wins) (" n_dupmap "):" > "/dev/stderr"
for (i = 1; i <= n_dupmap; i++) print " " dupmap[i] > "/dev/stderr"
}
}