Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Get LDAP-"Path" from WinNT object

Reply
 
Old 03-13-2009   #1 (permalink)
Albert Andersson


 
 

Get LDAP-"Path" from WinNT object

Hello

I Habe an Object, which represents the Current User:

Set objUser = GetObject("WinNT://" & strNetBIOSDomain & "/" _
& strNTName & ",user")

Whith this i can check if the user is in e specifict group. however,
nested groups doesn't work like this.

For nested Groups i've found a solution, but i need the LDAP-Path. Is
there a way to easly get that?

The objUser Object has some Attributes like .name or so but i dont find
i documentation about this. Maybe there is .Path Proberty or so?

My System SpecsSystem Spec
Old 03-13-2009   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: Get LDAP-"Path" from WinNT object

Albert Andersson wrote:
Quote:

>
> I Habe an Object, which represents the Current User:
>
> Set objUser = GetObject("WinNT://" & strNetBIOSDomain & "/" _
> & strNTName & ",user")
>
> Whith this i can check if the user is in e specifict group. however,
> nested groups doesn't work like this.
>
> For nested Groups i've found a solution, but i need the LDAP-Path. Is
> there a way to easly get that?
>
> The objUser Object has some Attributes like .name or so but i dont find i
> documentation about this. Maybe there is .Path Proberty or so?
If you have the NT Name of the user and the NetBIOS name of the domain you
can use the NameTranslate object to retrieve the Distinguished Name required
for the LDAP provider. See this link for details:

http://www.rlmueller.net/NameTranslateFAQ.htm

From #6, the quick example in the above link:
===========
' Constants for the NameTranslate object.

Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1

' Specify the NetBIOS name of the domain and the NT name of the user.
strNTName = strNetBIOSDomain& "\" & strNTName

' Use the NameTranslate object to convert the NT user name to the
' Distinguished Name required for the LDAP provider.
Set objTrans = CreateObject("NameTranslate")

' Initialize NameTranslate by locating the Global Catalog.
objTrans.Init ADS_NAME_INITTYPE_GC, ""
' Use the Set method to specify the NT format of the object name.
objTrans.Set ADS_NAME_TYPE_NT4, strNTName

' Use the Get method to retrieve the RPC 1779 Distinguished Name.
strUserDN = objTrans.Get(ADS_NAME_TYPE_1779)



' Bind to the user object in Active Directory with the LDAP provider.
Set objUser = GetObject("LDAP://" & strUserDN)


--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Old 03-13-2009   #3 (permalink)
Albert Andersson


 
 

Re: Get LDAP-"Path" from WinNT object

Danke ich habe es damit hinbekkommen.
Dieses Stück code werde ich nie mehr aus der Hand geben.

Richard Mueller [MVP] schrieb:
Quote:

> Albert Andersson wrote:
>
Quote:

>> I Habe an Object, which represents the Current User:
>>
>> Set objUser = GetObject("WinNT://" & strNetBIOSDomain & "/" _
>> & strNTName & ",user")
>>
>> Whith this i can check if the user is in e specifict group. however,
>> nested groups doesn't work like this.
>>
>> For nested Groups i've found a solution, but i need the LDAP-Path. Is
>> there a way to easly get that?
>>
>> The objUser Object has some Attributes like .name or so but i dont find i
>> documentation about this. Maybe there is .Path Proberty or so?
>
> If you have the NT Name of the user and the NetBIOS name of the domain you
> can use the NameTranslate object to retrieve the Distinguished Name required
> for the LDAP provider. See this link for details:
>
> http://www.rlmueller.net/NameTranslateFAQ.htm
>
> From #6, the quick example in the above link:
> ===========
> ' Constants for the NameTranslate object.
>
> Const ADS_NAME_INITTYPE_GC = 3
> Const ADS_NAME_TYPE_NT4 = 3
> Const ADS_NAME_TYPE_1779 = 1
>
> ' Specify the NetBIOS name of the domain and the NT name of the user.
> strNTName = strNetBIOSDomain& "\" & strNTName
>
> ' Use the NameTranslate object to convert the NT user name to the
> ' Distinguished Name required for the LDAP provider.
> Set objTrans = CreateObject("NameTranslate")
>
> ' Initialize NameTranslate by locating the Global Catalog.
> objTrans.Init ADS_NAME_INITTYPE_GC, ""
> ' Use the Set method to specify the NT format of the object name.
> objTrans.Set ADS_NAME_TYPE_NT4, strNTName
>
> ' Use the Get method to retrieve the RPC 1779 Distinguished Name.
> strUserDN = objTrans.Get(ADS_NAME_TYPE_1779)
>
>
>
> ' Bind to the user object in Active Directory with the LDAP provider.
> Set objUser = GetObject("LDAP://" & strUserDN)
>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Missing ?.NET? file in a C:\winnt\assembly "subdirectory" .NET General
"Open command prompt here" and "Copy as path" Vista performance & maintenance
Separate hashtable vs $alist | where-object { "key" = "value" } versus something else? PowerShell
[VBScript](Set objUser = GetObject("WinNT://" & strComputer)) -eq [Powershell]? PowerShell
False IE doc body error - "Object reference not set to an instance of an object" PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46