' Translate NT4 names to dn
'
private function TranslateNT4Name(nt4name)
dim nto
dim result
const ADS_NAME_INITTYPE_SERVER = 2
const ADS_NAME_INITTYPE_GC = 3
const ADS_NAME_TYPE_1779 = 1
const ADS_NAME_TYPE_NT4 = 3
set nto = CreateObject("NameTranslate")
on error resume next
nto.Init ADS_NAME_INITTYPE_GC , ""
if err then
wscript.echo
wscript.echo "ERROR: Couldn't create name translate object"
wscript.quit
end if
nto.set ADS_NAME_TYPE_NT4, nt4name
'
' If this fails we want it to just return a blank value
'
TranslateNT4Name = nto.Get(ADS_NAME_TYPE_1779)
on error goto 0
end function
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rich Milburn
Sent: Monday, November 03, 2003 10:53 AM
To: [EMAIL PROTECTED]
I've tried finding the answer to this and it's hiding from me (I bet 15 people will respond with a link I overlooked!!)
I want to pull a user object from AD in vbscript by typing a login name in a box, or passing it as a parameter... but I'm having trouble finding a way to do this without either having to type the full DN or know what OU the user is in. It seems easy but I've spent way too much time on it...
Here's the code:
strUser = InputBox("Enter object name to search for","Search for object")
Set objUser = GetObject("LDAP://CN=" & strUser & ",DC=domain,DC=com")
WScript.Echo objUser.userPrincipalName
This works if I add CN=Users or OU=___ and the object is in that container, but otherwise it just says object not found on the server. (oh and WScript.Echo is not the goal here, just a test J)
Thanks -
Rich
-------APPLEBEE'S INTERNATIONAL, INC. CONFIDENTIALITY NOTICE------- PRIVILEGED / CONFIDENTIAL INFORMATION may be contained in this message or any attachments. This information is strictly confidential and may be subject to attorney-client privilege. This message is intended only for the use of the named addressee. If you are not the intended recipient of this message, unauthorized forwarding, printing, copying, distribution, or using such information is strictly prohibited and may be unlawful. If you have received this in error, you should kindly notify the sender by reply e-mail and immediately destroy this message. Unauthorized interception of this e-mail is a violation of federal criminal law. Applebee's International, Inc. reserves the right to monitor and review the content of all messages sent to and from this e-mail address. Messages sent to or from this e-mail address may be stored on the Applebee's International, Inc. e-mail system.
