Click to Rate and Give Feedback
MSDN
MSDN Library
Directory Services
ADSI Interfaces
Core Interfaces
IADs
 IADs Property Methods
IADs Property Methods

The property methods of the IADs interface get or set the properties described in the following table. For more information about property methods, see Interface Property Methods.

Properties

PropertyDescription
ADsPath
Visual Basic
Access: Read-only
DataType: BSTR

C++HRESULT get_ADsPath([out] BSTR* pbstrADsPath);

The ADsPath string of this object. The string uniquely identifies this object in a network environment. The object can always be retrieved using this path.

Class
Visual Basic
Access: Read-only
DataType: BSTR

C++HRESULT get_Class([out] BSTR* pbstrClass);

The name of the object Schema class.

GUID
Visual Basic
Access: Read-only
DataType: BSTR

C++HRESULT get_GUID([out] BSTR* pbstrGUID);

The globally unique identifier of the directory object. The IADs interface converts the GUID from an octet string, as stored on a directory server, into a string format.

Name
Visual Basic
Access: Read-only
DataType: BSTR

C++HRESULT get_Name([out] BSTR* pbstrName);

The relative name of the object as named within the underlying directory service. This name distinguishes this object from its siblings.

Parent
Visual Basic
Access: Read-only
DataType: BSTR

C++HRESULT get_Parent([out] BSTR* pbstrParent);

The ADsPath string of the parent container. Active Directory does not permit the formation of the ADsPath of a given object by concatenating the Parent and Name properties. While this operation might work in some providers, it is not guaranteed to work for all implementations. The ADsPath is guaranteed to be valid and should always be used to retrieve an object's interface pointer.

Schema
Visual Basic
Access: Read-only
DataType: BSTR

C++HRESULT get_Schema([out] BSTR* pbstrSchema);

The ADsPath string of the Schema class object of this object.

 

Remarks

In Active Directory, the GUID returned from GUID is a string of hexadecimals. Use the resultant GUID to bind to the object directly.

Dim x As IADs
Set x = GetObject("LDAP://servername/<GUID=xxx>")

where xxx is the value returned from the GUID property. For more information, see Using objectGUID to Bind to an Object. Be aware that if you use a GUID to bind to an object, the Name, ADsPath, and Parent property methods return values that are different from the normal values that would be returned if you used a distinguished name (DN) to bind to the same object. For example, the following table lists the values returned when using the two different binding methods to bind to the same user object.

Bind using DNBind using GUID
NameCN=Jeff Smith<GUID=c0f59dfcf507d311a99e0000f879f7c7>
ParentLDAP://server/CN=Users,DC=Fabrikam,DC=comLDAP://server
ADsPathLDAP://server/CN=Jeff Smith,CN=Users,DC=Fabrikam,DC=comLDAP://server/<GUID=c0f59dfcf507d311a99e0000f879f7c7>

 

The GUID-binding technique returns values that may not be useful. For example, to bind to an object's parent to move or delete the object using the IADsContainer methods. To do this after binding to an object using a GUID, first rebind to the object using the DN and then use the second binding to retrieve the binding path for the parent object. The following code example shows how to do this.

' Bind to an object using its GUID.
Set objFromGUID = GetObject("LDAP://<GUID=c0f59dfcf507d311a99e0000f879f7c7>")

' Rebind to the object using its distinguished name.
Set objFromDN = GetObject("LDAP://" & objFromGUID.Get("distinguishedName"))

' Use the second binding to get the object's parent.
Set parent = GetObject(objFromDN.Parent)
Windows XP:  Binding with a GUID using the LDAP provider no longer returns a 'GUID ADsPath' for the Name and Parent property methods, and rebinding is not required when attempting to bind using the returned path strings. However, the ADsPath property method will still return a 'GUID ADsPath' when GUID binding is performed.

Note  The WinNT provider does not support binding using the object GUID, and returns the GUID property in a slightly different string format.

Note  The NDS and NWCOMPAT providers do not support binding using the object GUID.

Examples

The following code example shows how to retrieve object data using property methods of the IADs interface.

Dim x As IADs
Dim parent As IADsContainer
Dim cls As IADsClass
Dim op As Variant

On Error GoTo Cleanup

Set x = GetObject("WinNT://Fabrikam/Administrator")
Debug.Print "Object Name: " & x.Name
Debug.Print "Object Path: " & x.ADsPath
Debug.Print "Object Class: " & x.Class
 
' Get more data about the object schema.
Set cls = GetObject(x.Schema)
Debug.Print "Class Name is: " & cls.Name
For Each op In cls.OptionalProperties
    Debug.Print "Optional Property: " & op
Next op

Cleanup:
    If (Err.Number<>0) Then
        MsgBox("An error has occurred. " & Err.Number)
    End If
    Set x = Nothing
    Set parent = Nothing
    Set cls = Nothing

The following code example shows how to retrieve object data using property methods of the IADs interface.

<HTML>
<head><title></title></head>

<body>
<%
Dim x 
On Error Resume Next
 
Set x = GetObject("WinNT://Fabrikam/Administrator")
Response.Write "Object Name: " & x.Name & "<br>"
Response.Write "Object Path: " & x.ADsPath & "<br>"
Response.Write "Object Class: " & x.Class & "<br>"
 
' Get more data about the object schema.
Set cls = GetObject(x.Schema)
Response.Write "Class Name is: " & cls.Name & "<br>"
For Each op In cls.OptionalProperties
    Response.Write "Optional Property: " & op & "<br>"
Next op
%>

</body>
</html>

The following code example shows how to work with the property methods of the IADs interface.

#include <stdio.h>
#include <activeds.h>
 
int main(int argc, char* argv[])
{
    IADs *pADs = NULL;
    IADsUser *pADsUser = NULL;
    IADsClass *pCls = NULL;
    CComBSTR sbstr;
 
    HRESULT hr = CoInitialize(NULL);
    if (hr != S_OK) { return 0; }
 
    hr=ADsGetObject(L"WinNT://Fabrikam/Administrator",
                IID_IADsUser,
                (void**) &pADsUser);
    if (hr != S_OK) { goto Cleanup; }
 
    hr = pADsUser->QueryInterface(IID_IADs, (void**) &pADs);
    if( hr !=S_OK) { goto Cleanup;}
 
    pADsUser->Release();
 
    if( S_OK == pADs->get_Name(&sbstr) ) {
        printf("Object Name: %S\n",sbstr);
    }
 
    if( S_OK == pADs->get_ADsPath(&sbstr) ) {
        printf("Object path: %S\n",sbstr);
    }
 
    if( S_OK == pADs->get_Class(&sbstr) ) {
        printf("Object class: %S\n",sbstr);
    }
 
    hr = pADs->get_Schema(&sbstr);
    if ( hr != S_OK) {goto Cleanup;}
 
    hr = ADsGetObject(sbstr,IID_IADsClass, (void**)&pCls);
    if ( hr != S_OK) {goto Cleanup;}
    if( S_OK == pCls->get_Name(&sbstr) ) {
        printf("Class name is %S\n", sbstr);
    }
 
 Cleanup:
    if(pADs)
        pADs->Release();

    if(pIADsUser)
        pADsUser->Release();

    if(IADsClass)
        pADsClass->Release();

    CoUninitialize();

    if(hr==S_OK)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

Requirements

Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderIads.h
DLLActiveds.dll
IIDIID_IADs is defined as FD8256D0-FD15-11CE-ABC4-02608C9E7553

See Also

IADs
IADsContainer

Send comments about this topic to Microsoft

Build date: 11/12/2009

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker