Using ADSI to create a virtual directory

Source: Internet
Author: User
Tags date define definition iis connect sql naming convention domain name
Create | Virtual directory did you ever add a virtual directory through the VBS? (I want to) automatically establish an ISAPI server extension? or set up an entire site,


include permissions? You can do this and more with ADSI.





ADSI (Active Directory Services Interface) is an application data interface. Microsoft's operating system supports ads


i has Windows NT 4.0 Server, Exchange, IIS, and site Server. ADSI will become an operating system in Win2K


interface and may replace the registry. The key to ADSI is not the underlying data store, but its own interface layer. With a


interface, you can configure all server programs as long as you learn them once. (is not very cool Ah, hehe!) Unlike APIs, you can use


all languages or environments to access ADSI through COM. (This is something!)





Warning:


before running the example of this article, please back up IIS4.0:


Open MMC


(following the backup process omitted)





Object-oriented database








ADSI treats all data as objects. With ADSI you can manipulate all the data without learning a database


query languages such as SQL. It is simpler and faster to build an object-oriented database than a relational database. In a

In the
relational database, programmers have to know how an object is corrupted and stored, but object-oriented data storage, like ADSI


, there are no such problems. The programmer just knows the name of the object you want to visit.





in order to compare these two database types, imagine you want an employee's profile: personal information, departmental information, and salary information. In a

In the
relational database, these three data may be placed in three tables. and a change to the database may only affect its


part of the table, modifications to the database the programmer had to use a database query language such as SQL. Very few personnel to pay attention to object

How
is stored (in addition to the database administrator). However, ADSI treats all information as objects, and the connection between objects is the ADSI


part of the line, so this part is no longer needed by the programmer. Once you've learned to deal with an ADSI data, you've learned to


processes all ADSI databases. As a contrast, you may need to learn each relational database language if you want to use a different number of


according to the library. (like FoxPro)








Data Structure







The
database structure is a hierarchical model. An object node can be a parent of another node, a sibling node, or a child section


Point. Each child node inherits the properties of the parent node. The database has two logical sections. The first is the plan to define data and data associations.


the second part is the actual storage of the data. Define an employee object is placed in the Planning section, and the personal information is placed in the data section.











gets an instance of an object








Unlike COM, you don't have to use Server.CreateObject to get an instance of an ADSI object. You just use GetObject side


method and a parameter that specifies the server and the location of the join. Example one has two examples of GetObject. In the first case, the code is built


A Windows NT ADSI instance. Each two example obtains an ADSI object for IIS.


Example 1








for Windows NT





Set Object = GetObject ("Winnt://15seconds")





for LDAP





Set Object = GetObject ("IIS://LOCALHOST/W3SVC/1")








Some ad service interfaces use a special naming convention called the X.500 luxury name. IIS does not use this rule but you have to


a naming convention for X.500 because you might also want to manipulate other ADSI data. You can
.

obtained relevant information from Ftp://src.doc.ic.ac.uk/rfc/rfc1484.txt.








Data Retrieval








when we look for information on an LDAP server, we have to know whether the information is in the instance or in the Planning section. Give an example


, an object name can be contained in an object instance, but a list of object attributes will be stored in a planning department


. The employee name, date of hire, and department are stored in the Employee object. The Plan section stores the definition of an employee attribute as a data type.

The
example illustrates the definition of an object instance and an object plan.


Example 2








Employee Instance


Name:bob Jones


Hire date:1/1/98


department:information Technology





Employee Object Instance


Attribute "Name", single value, Data-type "text", MaxLength 50 "


Attribute "Hire date", single value, Data-type "Date"


Attribute "Department", single value, Data-type "text"





for SQL programmers, the definition of an object is similar to that of a table. An object instance is like a specific row in a table. SQL

The difference between
and ADSI is whether the data spans multiple tables, and the programmer needs to manage the relationship between the data. In ADSI, connect


is responsible for these relationships.





The default Web site's Pass properties


The first example will see the properties of the default Web site for IIS4.0. In Example 3, the code joins to the local machine's default Web site.


Example 3








<%


strmachinename = "localhost" ' Domain name


Strobjectpath = "W3SVC/1" ' Object name





' construct object location in IIS


strpath = "iis://" & strMachineName & "/" & Strobjectpath


Set iisobject = GetObject (strpath) ' Connect to IIS metabase


%>


Name = "<%= iisobject.name%>"





parent= "<%= iisobject.parent%>"





schemalocation = "<%= iisobject.schema%>"





Class = "<%= iisobject.class%>"





Guid = "<%= iisobject.guid%>"





ADSPath = "<%= iisobject.adspath%>"











output display is:





Name = "1"


parent= "Iis://localhost/w3svc"


schemalocation = "Iis://localhost/schema/iiswebserver"


Class = "IIsWebServer"


Guid = ' {8b645280-7ba4-11cf-b03d-00aa006e0975} '


ADSPath = "IIS://LOCALHOST/W3SVC/1"











Note: If you want to run this program in an ASP page, make sure that the logged in user is granted administrator privileges.





in the last example of data retrieval can be used with any object, including the Plan object. Every object whether he is a real


object or a plan object must have these attributes: name, parent, plan, Class,guid, and ads path.








This information includes some navigation information for accessing data through a hierarchical structure. The Name property is the names of an object. A parent


tells the location of the parent object. The SchemaLocation property refers to the location of the Plan object. The class attribute includes the type of the object,


It consisted of all attributes of an object and was set to schemalocation this position. The GUID property is the only
of an object

Identification code. ADsPath is the location of the object you retrieved.








Note: A server named 1 represents the default Web site








the properties of the default Web site


Now that we know the location of the object and the type of object, let's take a look at the properties of the default Web site. In order to achieve


for this purpose, we have to get the default Web site's schedule (schema), find the relevant attributes, and look at the default Web site's


the values of some properties.


Example 4








<%


strmachinename = "localhost"


Strobjectpath = "W3SVC/1" ' Find the Web server listed in w3svc


strpath = "iis://" & strMachineName & "/" & Strobjectpath


Set iisobject = GetObject (strpath)





' Find location of







Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.