VBScript Active Directory LDAP ANR Query

Here’s a really simple Active Directory ANR (Ambiguous Name Resolution) query that uses VBScript and ADO.
name = "ian"

Set objDomain = GetObject ("LDAP://rootDSE")
Set conn = CreateObject("ADODB.Connection")
conn.provider ="ADsDSOObject"
conn.open "Active Directory Provider"
Set Comm = CreateObject("ADODB.Command")
Set Comm.ActiveConnection = conn
Comm.CommandText = "<LDAP://" & objDomain.get("defaultnamingcontext") & ">;(&(objectCategory=User)(anr=" + name + "));displayName,AdsPath;subtree"

Set rs = Comm.Execute
Set objUser = GetObject(rs.Fields("ADsPath").Value)

msgbox objUser.Get("mail")