Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADSI Syntax? 2

Status
Not open for further replies.

PScottC

MIS
Mar 16, 2003
1,285
US
I don't understand why the following code works:

Code:
Option Explicit
Dim strDN, member, objGroup

strDN = "CN=Domain Admins,CN=Users,DC=domain,DC=tld"
Set objGroup = GetObject("LDAP://" & strDN)

WScript.Echo "sAMAccountName: " & objGroup.sAMAccountName
WScript.Echo "cn:             " & objGroup.cn
WScript.Echo "description:    " & objGroup.description
WScript.Echo "members:        "
For Each member In objGroup.members
	WScript.Echo "                " & member.distinguishedName
Next

All the documentation online says that I should use this syntax:
Code:
Option Explicit
Dim strDN, member, objGroup

strDN = "CN=Domain Admins,CN=Users,DC=domain,DC=tld"
Set objGroup = GetObject("LDAP://" & strDN)

WScript.Echo "sAMAccountName: " & objGroup.Get("sAMAccountName")
WScript.Echo "cn:             " & objGroup.Get("cn")
WScript.Echo "description:    " & objGroup.Get("description")
WScript.Echo "members:        "
For Each member In objGroup.GetEx("member")
	WScript.Echo "                " & member
Next

Where do I find a list of the properties I can retrieve using the first example? Using example 1 syntax, I can't seem to access all of the object attributes from AD (Such as canonicalName)

Thanks in advance!


PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
Thanks tsuji. The link you posted sends me to the documentation that I have been looking at, which suggests using the .Get, .GetEx, etc... methods to acquire data from AD.

When I build scripts, I usually look at code samples posted on the internet to help me understand what I am trying to accomplish. In this instance, I found some examples where the syntax in sample 1 above was used and I was trying to find out where that is documented.

Is the syntax of sample 1 depricated? Should I only use the syntax of sample 2?

This all started from me trying to acquire the canonicalName attribute (not cn) of a group in AD. It turns out that the property is an "operational" attribute and must be acquired with the .GetInfoEx method.

Sorry for the story of my life... [smile]

Thanks!

PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
[1]
>Is the syntax of sample 1 depricated? Should I only use the syntax of sample 2?
It is not a matter of deprecation. It is a matter of design characteristic. These are the factors (maybe not incomplete) affecting their uses or choices one over the others.
[ul]
[li]presence of schema[/li]
[li]automation interface[/li]
[li]property cache[/li]
[li]default property load caching[/li]
[li]return types[/li]
[li]traffic optimization[/li]
[li]committal and overwritting to and from cache[/li]
[/ul]
[2]
>In this instance, I found some examples where the syntax in sample 1 above was used and I was trying to find out where that is documented.
The dot notation is mentioned in the first page. It is not undocumented; and it is not deprecated neither.
 
Ok. Thanks for confirming that I'm not insane. I went through those docs pretty fast yesterday, but I guess it didn't sink in. What confused me is this page:
[URL unfurl="true"]http://msdn2.microsoft.com/en-us/library/aa706033(VS.85).aspx[/url]

It doesn't list all of the possible properties like I thought it should. (i.e. .sAMAccountName, .cn, etc...) I guess its hard to document a complex system fully. [evil] (Thanks Mr. Bill)

Have a star.

Thanks!


PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
PSC, you should use ADSIEdit to be able to see all of the properties for a given object in AD.

As an alternative you can also use ADExplorer.


Note: Ad Explorer only seems to show you attributes that are populated. Use ADSIEdit to see all available attributes.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Thanks for the link. Looking at that page, I never would have guessed. I learn something new every day.

PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top