Directory Service Technology Introduction--ADSI (V)

Source: Internet
Author: User
Tags ldap
Because the identity name of the directory object may be changed under the influence of some operations, the objectGUID property of the directory object will never change, so we can specify this GUID directly in the LDAP path, and the client program binds directly to this object, and the following code shows this usage:
IADs *pads;
LPWSTR pszfilter = L "ldap://myserver/<guid=63560110f7e1d111a6bfaaaf842b9cfa>";
hr = ADsGetObject (Pszfilter, Iid_iads, (void**) &pads);
The equivalent VB code is as follows:
Dim MyObject as IADs
Set myObject = GetObject ("ldap://<guid=63560110f7e1d111a6bfaaaf842b9cfa>")
(2) enumeration operation of the package container object.
The client program through the above method can directly reach the specified directory object or package container object, we can also start from a node to access the directory subtree, using the IADsContainer interface provided by the method, we can implement enumeration operations, for example:
Dim MyObject as IADs
Dim Child as IADs
Dim Container as IADsContainer

On Error Resume Next
Set MyObject = GetObject ("Ldap://myserver")
Set Container = MyObject
If ERR = 0 Then
For each child in Container
Debug.Print Child.name
Next Child
EndIf
With this enumeration operation, we can access all package container objects and directory objects in the directory subtree.
(3) Read the properties of the directory object.
The easiest way to read an object's properties is to pass directly through the object's Iads::get or Iads::getex interface member functions, such as:
Dim MyUser as IADs
Dim Mycommonname as String
Set myuser = GetObject ("Winnt://myserver/myname")
Mycommonname = Myuser.get ("Fullname")
Of course, if we already know the other interfaces of the directory object, we can also access the properties in a more direct way, such as:
Dim MyUser as IADsUser
Dim MyName as String
Set myuser = GetObject ("Winnt://myserver/myname")
MyName = Myuser.fullname
When a client accesses a directory object, it is common for ADSI to cache the properties of the object. When an object is created, its property cache is empty, and if the client invokes Iads::getinfo to mount the object property from the underlying directory service, it fills the cache because either get or other Get_propertymethod functions implicitly invoke the GetInfo function. So the customer simply calls the GET function to fetch the property value, and the later get function reads the property value directly from the cache. You can explicitly call the Iads::getinfo function if the client program wants to flush the property values in the cache. Using caching avoids the frequent reading of attribute data from the server, thereby reducing network burden.

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.