?
Solved

ADSI object attributes

Posted on 2005-03-23
15
Medium Priority
?
473 Views
Last Modified: 2013-11-23
Given something like,

Set objRootDSE = GetObject("LDAP://RootDSE")

How can I find the attributes of this object?
0
Comment
Question by:DaveChoiceTech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 3
  • 3
  • +2
15 Comments
 
LVL 5

Assisted Solution

by:beryl666
beryl666 earned 900 total points
ID: 13614517
Reading the objectClassCategory Attribute of Several Classes
arrClassNames = Array _
 ("cn=top","cn=mail-Recipient", "cn=security-Principal", _
 "cn=person", "cn=Organizational-Person", _
 "cn=contact", "cn=user", "cn=computer", "cn=organizational-Unit")
 
Set objRootDSE = GetObject("LDAP://rootDSE")
For Each ClassName in arrClassNames
 Set objSchemaClass = GetObject("LDAP://" & ClassName & "," & _
 objRootDSE.Get("schemaNamingContext"))

 intClassCategory = objSchemaClass.Get("objectClassCategory")
 WScript.STDOUT.Write ClassName & " is "
 Select Case intClassCategory
 Case 0
 Wscript.Echo "88"
 Case 1
 Wscript.Echo "structural"
 Case 2
 Wscript.Echo "abstract"
 Case 3
 Wscript.Echo "auxiliary"
 End Select
Next

refer this to understand more:
http://www.asia.microsoft.com/technet/scriptcenter/guide/sas_ads_ftdm.mspx
0
 
LVL 23

Assisted Solution

by:gecko_au2003
gecko_au2003 earned 300 total points
ID: 13614523
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adsi/adsi/accessing_attributes_with_adsi.asp

There is a url that microsoft provides, if you look to the left it has related topics on Get and GetEx and such like. I hope that helps you out :)
0
 

Author Comment

by:DaveChoiceTech
ID: 13614734
Thanks for both answers. Give me a chance to review them and I'll settle up the points but first here is some background for the reason I was asking the original question.

This scriptlet works

set odomain = getobject("LDAP://RootDSE")
wscript.echo odomain.dnshostname
wscript.echo odomain.dsservicename

however this doesn't

set odomain = getobject("LDAP://RootDSE")
wscript.echo odomain.dsservicename

Only one line was removed! What is going on?

0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 22

Accepted Solution

by:
JesterToo earned 300 total points
ID: 13616022
I believe the rationale is:

Because an AD forest can contain multiple domains, the dsservicename property needs to be bound to a domain before it can be retrieved.  The removed statement provides a "default" binding to the domain in which the "directory services" server has been defined.  Without that statement the dsservicename property was not found to any domain.

There are probably more formal ways to achieve the domain binding that are more intuitive, but info. regarding many aspects of the intricacies of ADSI are difficult to come by out on the web.  If you find yourself doing very much with ADSI then a good book on the topic will make the tasks easier.  There are several titles available and can be easily found by googling for:  book ADSI.

HTH,
Lynn
0
 

Author Comment

by:DaveChoiceTech
ID: 13616556
Lynn,

That sounds good but may not be the answer since I found that using "Get" as shown below works fine. My guess is that there is something going on with caching and timing. Seems that working with attributes in Vbscript is kinda of buggy. I don't want to flog this to death but I'll leave the question open for a day or two since I always like to here expert opions such as you have offered. I appreciate you help.

Thanks,
Dave


set odomain = getobject("LDAP://RootDSE")
'wscript.echo odomain.dnshostname
'wscript.echo odomain.dsservicename
strfoo = odomain.Get("dsServicename")
WScript.Echo strfoo

0
 
LVL 22

Expert Comment

by:JesterToo
ID: 13617255
You may be correct, Dave.

Actually, I don't think VBScript is "at fault" here... it's more likely to be anomalies within ADSI itself.  My guess (no docs seem to cover the internal workings in any detail) is that with the "more formalized" GET method that there is an internal method call to retrieve the default naming context property and that without the GET, it is relying on that property to have already been established by some other means.  If true, this would seem to be a bit "sloppy" to me so I guess the lesson of the story is to try to use only established/documented protocols for setting/retrieving properties.

I, too, will be interested to hear others' opinions on this :-)

Regards,
Lynn
0
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 13617967
You talk about Get but there is no mention of GetEx as stated in the documenation, is there any difference between Get and GetEx ?
0
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 13617980
I mean in terms of speed or the ability to get the information without any bugs as you stated.
0
 
LVL 22

Expert Comment

by:JesterToo
ID: 13618924
The "Get" method is used to return the value of a property which can have at most 1 value.  "GetEx" is used to return values from properties which can have multiple values... it can also be used in place of Get for single-valued properties.

Both of those methods implicitly call the GetInfo method.

Here is a pretty good article describing, in part, what I was referring to above about ADSI being somewhat inconsistent in how you can access the various properties...  http://www.windowsitpro.com/Article/ArticleID/4991/4991.html

Here's one key excerpt from that article...

Unlike the six core properties, not all object properties have explicit property methods that you can use to retrieve properties. However, you can implicitly access an object's property by treating the property as the method in automation languages, such as VBScript, JScript, and Visual Basic (VB). In nonautomation languages, such as Visual C++ (VC++), you must use the IADs Get method for any property that doesn't have an explicit property method. You need to check the ADSI documentation to determine whether property methods exist. (For more information about where you can find the ADSI documentation, see "An ADSI Primer, Part 1," January 1999.)

This article is part 3 of a 12-part series on ADSI.

All in all, I'm grateful for the existence of ADSI.  But, it seems to have been designed/constructed by committee without much thought towards a consistent interface.

-- Lynn
0
 
LVL 1

Expert Comment

by:jangeador
ID: 13622510
There is a tool that I use to determine wether I should use Get or GetEx. This tool is called ADSIEdit.msc, and it lets me browse through all the properties and objects in the AD schema.

http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=49ae8576-9bb9-4126-9761-ba8011fabf38

jangeador
0
 

Author Comment

by:DaveChoiceTech
ID: 13625418
There was no "answer" to the original question but everyones comments were helpful. Accordingly I have split the points.
Cheers,
Dave
0
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 13625444
Than Q Dave for the grade and points.
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about problems I had with the new location API and permissions in Marshmallow
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Introduction to Processes

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question