Link to home
Start Free TrialLog in
Avatar of kevaroo
kevarooFlag for United Kingdom of Great Britain and Northern Ireland

asked on

An invalid dn syntax has been specified - VBScript to rename a group in AD2000

Hi,

I am trying to write a VBscript that will rename a mail enabled group in AD 2000 and then amend some of the attributes. If I hard code the LDAP query it works fine, but when I try to use a variable for the input  of the group names it falls over at the below line  

objDomain.MoveHere "LDAP://cn=" & strCurrentName & ",ou=Distribution Lists,dc=domain,dc=net", "cn=" & strNewName &""

the error message is

Char: 1
Error: An invalid dn syntax has been specified
Code: 80072032
Source: (null)
dim strCurrentName, strNewName
 
strCurrentName = InputBox ("Group Name to be Renamed:","Enter Current Group Name")
  if strCurrentName = "" then
  wscript.quit
  end if
 
strNewName = InputBox ("New Name of Group:","Enter New Group Name")
  if strNewName = "" then
  wscript.quit
  end if
 
Set objDomain = GetObject("LDAP://cn=" & strCurrentName & ",ou=Distribution Lists,dc=domain,dc=net")
 
objDomain.MoveHere "LDAP://cn=" & strCurrentName & ",ou=Distribution Lists,dc=domain,dc=net", "cn=" & strNewName &""
 
set objuser = GetObject("LDAP://cn=" & strNewName & ",ou=Distribution Lists,dc=domain,dc=net")
 
objUser.sAMAccountName = strNewName
objuser.displayName = strNewName
objuser.mailNickname = strNewName
objUser.SetInfo
MsgBox("Finished")

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kevaroo

ASKER

Cheers Chris your solution is spot on

Kev
Avatar of kevaroo

ASKER

Thanks alot Chris,

Your soltuion works fine.

Kev

Always a pleasure :)

Chris