Script the whole thing! This script should work - put your own surname in place 
of mine and you should see that it edits your own details successfully. Then 
remove the comment from the second sSQL= line and it should process all 
mailboxes.
 
The "proper" function is a kludge; will take CHIANESE, DAVID and give you 
Chianese, David; it will also cope with (eg) O'Connor and McCormack type names 
but I'm sure that there are other scenarios it doesn't know about that need 
capitals other than after the spaces - this is left as an exercise for the 
reader :-)
 
Steve
 
set oRS=createobject("adodb.recordset")
set oConn=createobject("adodb.connection")
sConn="provider=ADSDSoObject"
oConn.open sConn
Set oRootDSE=GetObject("LDAP://RootDSE")
sRoot=oRootDSE.Get("DefaultNamingContext")
sGroup=wscript.arguments.named("group")
sSQL="select distinguishedname from 'LDAP://" & sRoot & "' where sn='Rochford'"
'sSQL="select distinguishedname from 'LDAP://" & sRoot & "' where 
objectCategory='person' and objectClass='user' and homeMDB='*' and 
msExchHomeServerName='*'"
ors.open sSQL, oConn
do while not ors.eof
  sDN=ors("distinguishedname")
  set oUser=getobject("LDAP://" & sDN)
  sDisplayName=proper(oUser.displayName)
  wscript.echo sDisplayName
  oUser.DisplayName=sDisplayName
  oUser.setinfo
  ors.movenext
loop
ors.close

Function proper(s)
 If isnull(s) Or s="" Then
  proper=""
 Else
  a = split(s," ")
  'convert first letters to upper case
  For i=0 To ubound(a)
    a(i)=ucase(left(a(i),1)) & lcase(mid(a(i),2))
    if mid(a(i),2,1)="'" then a(i)=left(a(i),2) & ucase(mid(a(i),3,1)) & 
mid(a(i),4)
    if left(a(i),2)="Mc" then a(i)=left(a(i),2) & ucase(mid(a(i),3,1)) & 
mid(a(i),4)
  Next
  s=join(a) 'assumes space
  proper=s
 End If
End Function


________________________________

From: [EMAIL PROTECTED] on behalf of CHIANESE, DAVID
Sent: Tue 13/12/2005 19:11
To: [email protected]
Subject: RE: [ActiveDir] csv to ldf converter


They are all caps and I want them proper case.  Or actually management wants 
them that way.  :)
 
We have this:
On 12/13/05, CHIANESE, DAVID <[EMAIL PROTECTED]> wrote: 
 
We want this:
On 12/13/05, Chianese, David <[EMAIL PROTECTED]> wrote: 

<<winmail.dat>>

Reply via email to