Share via


Getting the Value of a Specific Property On an Object

Getting the Value of a Specific Property On an Object

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

The following example returns the value of the specified property on the given object.

Visual Basic

'//////////////////////////////////////////////////////////////////////
' Function: getValue()
' Purpose:  Returns the value of the specified property on the given object.
'
' Input:    szConnString:         LDAP path of object
'           szProperty:           Name of property
'           value:                Value of property
'           szAdminUserName:      Administrator user name
'           szAdminPassword:        Administrator password
'
' Output:   getValue:             Contains Error code (if any)
'           value:                Contains the value of the property
'
' Note:  In order for this example to function correctly, it may be necessary to include
' references to the following libraries: Active DS Type Library, Microsoft CDO for
' Exchange Management Library, Microsoft Cluster Service Automation Classes,
' Microsoft CDO for Windows 2000 Library.
'//////////////////////////////////////////////////////////////////////
Public Function getValue(ByVal szConnString As String, _
                         ByVal szProperty As String, _
                         ByRef value As Variant, _
                         ByVal szAdminUserName, _
                         ByVal szAdminPassword) As Integer

    ' Get the value requested on the sent object.

    Dim objLdap As IADsOpenDSObject
    Dim objObject As IADs

    On Error GoTo errhandler

    Set objLdap = GetObject("LDAP:")

    ' Get a container object from the connection string.

    Set objObject = objLdap.OpenDSObject(szConnString, _
                                         szAdminUserName, _
                                         szAdminPassword, _
                                         ADS_SECURE_AUTHENTICATION)

    value = objObject.Get(szProperty)
    getValue = 0

    ' Clean up.
    Set objLdap = Nothing
    Set objObject = Nothing
    Exit Function

    ' Error handling.
errhandler:

    Set objLdap = Nothing
    Set objObject = Nothing
    getValue = 1
    ' Implement error logging here.
    Exit Function

End Function

Send us your feedback about the Microsoft Exchange Server 2003 SDK.

Build: June 2007 (2007.618.1)

© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.