Returning an AD Distinguished name in script

W

Warren Oldroyd

Hi,

I'm using vbscript and trying to figure out how to find
out the full distinguished name for a user object if I'm
passed the user's login name.

For example, if the external prog passes me 'foo.bar' as
the users login name, how can I find the
full 'cn=foo.bar, ou=test, ou=test2, dc=domain, dc=local'
distinguished name string?

I can't help but feel I'm missing something obvious here,
but it's foxing me completely at the moment!

Any links or sample script or other hint would be greatly
appreciated...
 
J

Joe Richards [MVP]

Take a look at the NameTranslate object...

Here is an example

'
' 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

TranslateNT4Name=""
set nto = CreateObject("NameTranslate")
on error resume next
nto.Init ADS_NAME_INITTYPE_GC , ""
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top