This is a multi-part message in MIME format.

------=_NextPart_000_0055_01C3B99C.D1393590
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Can someone tell me how the code would look to change the UserID in =
Active Directory from say lastname to firstinitiallastname.

For instance: the code in RED below. Instead of echoing the value I =
want to change it.

Set objSysInfo =3D CreateObject ("ADSYstemInfo")



Set objUser =3D GetObject("LDAP://" & objSysInfo.UserName)
objUser.GetInfo

'Set objDomain =3D GetObject("LDAP://" & objSysInfo.DomainDNSName)
'objDomain.GetInfo



strDisplayName =3D objUser.Get("displayName")
strDescription =3D objUser.Get("description")
strUserName =3D objUser.Get("cn")
strUserOu =3D objUser.Get("DistinguishedName")
strUserPrincipalName =3D objUser.Get("UserPrincipalname")
strUserLastName =3D objUser.Get("sn")
strUserFirstName =3D objUser.Get("givenName")
strUserEmail =3D objUser.Get("mail")




'WScript.Echo strUsername
'WScript.Echo strDnsDomainName
'WScript.Echo strDomainShortName
'WScript.Echo strDisplayName
'WScript.Echo strDescription


WScript.Echo "User Logon ID:..............................." & =
strUserName & vbCrLf & _
"User Principal Name:........................." & strUserPrincipalName & =
vbCrLf & _
"User Full Name:..............................." & strUserLastName & ", =
" & strUserFirstName & vbCrLf & _
"Users Email Address:........................." & strUserEmail & vbCrLf =
& _
"User Account in OU:........................." & strUserOu & vbCrLf & _
"User Site:......................................" & objSysInfo.SiteName =
& vbCrLf & _
"User Description.............................." & strDescription & =
vbCrLf & _
"Current Logon DNS Domain Name:........" & objSysInfo.DomainDnsName & =
vbCrLf & _
"Current Logon NetBIOS Domain Name:..." & objSysInfo.DomainShortName
------=_NextPart_000_0055_01C3B99C.D1393590
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1264" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Can someone tell me how&nbsp;the code =
would look to=20
change the UserID in Active Directory from say lastname to=20
firstinitiallastname.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>For instance: the code in RED =
below.&nbsp; Instead=20
of echoing the value I want to change it.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Set objSysInfo =3D CreateObject=20
("ADSYstemInfo")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Set objUser =3D GetObject("LDAP://" =
&amp;=20
objSysInfo.UserName)<BR>objUser.GetInfo</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>'Set objDomain =3D GetObject("LDAP://" =
&amp;=20
objSysInfo.DomainDNSName)<BR>'objDomain.GetInfo</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>strDisplayName =3D=20
objUser.Get("displayName")<BR>strDescription =3D=20
objUser.Get("description")<BR>strUserName =3D =
objUser.Get("cn")<BR>strUserOu =3D=20
objUser.Get("DistinguishedName")<BR>strUserPrincipalName =3D=20
objUser.Get("UserPrincipalname")<BR>strUserLastName =3D=20
objUser.Get("sn")<BR>strUserFirstName =3D =
objUser.Get("givenName")<BR>strUserEmail=20
=3D objUser.Get("mail")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><BR><FONT face=3DArial size=3D2><STRONG><FONT =
color=3D#ff0000>'WScript.Echo=20
strUsername<BR></FONT></STRONG>'WScript.Echo =
strDnsDomainName<BR>'WScript.Echo=20
strDomainShortName<BR>'WScript.Echo strDisplayName<BR>'WScript.Echo=20
strDescription</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><BR><FONT face=3DArial size=3D2>WScript.Echo "User Logon=20
ID:..............................." &amp; strUserName &amp; vbCrLf &amp; =

_<BR>"User Principal Name:........................." &amp; =
strUserPrincipalName=20
&amp; vbCrLf &amp; _<BR>"User Full Name:..............................." =
&amp;=20
strUserLastName &amp; ", " &amp; strUserFirstName &amp; vbCrLf &amp; =
_<BR>"Users=20
Email Address:........................." &amp; strUserEmail &amp; vbCrLf =
&amp;=20
_<BR>"User Account in OU:........................." &amp; strUserOu =
&amp; vbCrLf=20
&amp; _<BR>"User Site:......................................" &amp;=20
objSysInfo.SiteName &amp; vbCrLf &amp; _<BR>"User=20
Description.............................." &amp; strDescription &amp; =
vbCrLf=20
&amp; _<BR>"Current Logon DNS Domain Name:........" &amp;=20
objSysInfo.DomainDnsName &amp; vbCrLf &amp; _<BR>"Current Logon NetBIOS =
Domain=20
Name:..." &amp; objSysInfo.DomainShortName</FONT></DIV></BODY></HTML>

------=_NextPart_000_0055_01C3B99C.D1393590--

Re: Change the cn attribute by Richard

Richard
Wed Dec 03 16:01:41 CST 2003

This is a multi-part message in MIME format.

------=_NextPart_000_0045_01C3B9B6.BE69D860
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,

You cannot modify the cn attribute like you can others. Because it is =
the Relative Distinguished Name of the object, you must use the MoveHere =
method of the parent container to rename the object. For example, to =
rename the current user to "cn=3DJSmith":

Set objSysInfo =3D CreateObject("ADSystemInfo")
Set objUser =3D GetObject("LDAP://" & objSysInfo.UserName)
Set objParent =3D GetObject(objUser.Parent)
Set objNewUser =3D objParent.MoveHere(objUser.AdsPath, "cn=3DJSmith")

--=20
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site - http://www.rlmueller.net
--

"Roger" <hainesr3@nationwide.com> wrote in message =
news:eg0Wr8cuDHA.2168@TK2MSFTNGP10.phx.gbl...
Can someone tell me how the code would look to change the UserID in =
Active Directory from say lastname to firstinitiallastname.

For instance: the code in RED below. Instead of echoing the value I =
want to change it.

Set objSysInfo =3D CreateObject ("ADSYstemInfo")



Set objUser =3D GetObject("LDAP://" & objSysInfo.UserName)
objUser.GetInfo

'Set objDomain =3D GetObject("LDAP://" & objSysInfo.DomainDNSName)
'objDomain.GetInfo



strDisplayName =3D objUser.Get("displayName")
strDescription =3D objUser.Get("description")
strUserName =3D objUser.Get("cn")
strUserOu =3D objUser.Get("DistinguishedName")
strUserPrincipalName =3D objUser.Get("UserPrincipalname")
strUserLastName =3D objUser.Get("sn")
strUserFirstName =3D objUser.Get("givenName")
strUserEmail =3D objUser.Get("mail")




'WScript.Echo strUsername
'WScript.Echo strDnsDomainName
'WScript.Echo strDomainShortName
'WScript.Echo strDisplayName
'WScript.Echo strDescription


WScript.Echo "User Logon ID:..............................." & =
strUserName & vbCrLf & _
"User Principal Name:........................." & strUserPrincipalName =
& vbCrLf & _
"User Full Name:..............................." & strUserLastName & =
", " & strUserFirstName & vbCrLf & _
"Users Email Address:........................." & strUserEmail & =
vbCrLf & _
"User Account in OU:........................." & strUserOu & vbCrLf & =
_
"User Site:......................................" & =
objSysInfo.SiteName & vbCrLf & _
"User Description.............................." & strDescription & =
vbCrLf & _
"Current Logon DNS Domain Name:........" & objSysInfo.DomainDnsName & =
vbCrLf & _
"Current Logon NetBIOS Domain Name:..." & objSysInfo.DomainShortName
------=_NextPart_000_0045_01C3B9B6.BE69D860
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1276" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Hi,</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>You cannot modify the cn attribute like you can =
others.=20
Because it is the Relative Distinguished Name of the object, you must =
use the=20
MoveHere method of the parent container to rename the object. For =
example, to=20
rename the current user to "cn=3DJSmith":</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Set objSysInfo =3D =
CreateObject("ADSystemInfo")</FONT></DIV>
<DIV><FONT size=3D2>Set objUser =3D GetObject("LDAP://" &amp;=20
objSysInfo.UserName)</FONT></DIV>
<DIV><FONT size=3D2>Set objParent =3D =
GetObject(objUser.Parent)</FONT></DIV>
<DIV><FONT size=3D2>Set objNewUser =3D =
objParent.MoveHere(objUser.AdsPath,=20
"cn=3DJSmith")</FONT></DIV>
<DIV><FONT size=3D2><BR>-- <BR>Richard<BR>Microsoft MVP Scripting and=20
ADSI<BR>HilltopLab web site - <A=20
href=3D"http://www.rlmueller.net">http://www.rlmueller.net</A><BR>--</FON=
T></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Roger" &lt;<A=20
=
href=3D"mailto:hainesr3@nationwide.com">hainesr3@nationwide.com</A>&gt; =
wrote in=20
message <A=20
=
href=3D"news:eg0Wr8cuDHA.2168@TK2MSFTNGP10.phx.gbl">news:eg0Wr8cuDHA.2168=
@TK2MSFTNGP10.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>Can someone tell me how&nbsp;the code =
would look=20
to change the UserID in Active Directory from say lastname to=20
firstinitiallastname.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>For instance: the code in RED =
below.&nbsp;=20
Instead of echoing the value I want to change it.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Set objSysInfo =3D CreateObject=20
("ADSYstemInfo")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Set objUser =3D GetObject("LDAP://" =
&amp;=20
objSysInfo.UserName)<BR>objUser.GetInfo</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>'Set objDomain =3D =
GetObject("LDAP://" &amp;=20
objSysInfo.DomainDNSName)<BR>'objDomain.GetInfo</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>strDisplayName =3D=20
objUser.Get("displayName")<BR>strDescription =3D=20
objUser.Get("description")<BR>strUserName =3D =
objUser.Get("cn")<BR>strUserOu =3D=20
objUser.Get("DistinguishedName")<BR>strUserPrincipalName =3D=20
objUser.Get("UserPrincipalname")<BR>strUserLastName =3D=20
objUser.Get("sn")<BR>strUserFirstName =3D=20
objUser.Get("givenName")<BR>strUserEmail =3D =
objUser.Get("mail")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><BR><FONT face=3DArial size=3D2><STRONG><FONT =
color=3D#ff0000>'WScript.Echo=20
strUsername<BR></FONT></STRONG>'WScript.Echo =
strDnsDomainName<BR>'WScript.Echo=20
strDomainShortName<BR>'WScript.Echo strDisplayName<BR>'WScript.Echo=20
strDescription</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><BR><FONT face=3DArial size=3D2>WScript.Echo "User Logon=20
ID:..............................." &amp; strUserName &amp; vbCrLf =
&amp;=20
_<BR>"User Principal Name:........................." &amp;=20
strUserPrincipalName &amp; vbCrLf &amp; _<BR>"User Full=2