Novell Home

TID102456 (DXAlInfo) - Delphi Sample: Getting the Aliased Object Name with ActiveX Controls

From Developer Community

AUTHOR: WSC DOCUMENT ID: TID102456 DOCUMENT REVISION: DATE: 2001/06/8 8:30 AM ALERT STATUS: Yellow INFORMATION TYPE: Issue README FOR: DXALINFO.EXE NOVELL PRODUCT CLASS:

NetWare API

NOVELL PRODUCT and VERSION:

NetWare NDK Feb01

CATEGORY:

none

COMPILER:

Delphi 4.0

TARGET OS:

Windows 98

ABSTRACT:

DXAlInfo is a Delphi application that illustrates the use of Delphi with NetWare ActiveX controls.

It will specifically use the Directory Query control to retrieve the name of the Aliased object.

To understand the sample, assume that you have a user object "Admin" and an Alias object "Chef" that refers to that user object.

The problem with reading Alias objects through ActiveX controls is that the controls automatically dereference the Alias objects. If you read an Alias object (e.g., "Chef") into an NWEntry variable, all subsequent operations will work on the Aliased Object ("Admin"). Also properties like Entry.Layout.Name will return the layout of the Aliased object, instead of returning the layout name "Alias".

You cannot even read the only (mandatory) attribute of an Alias object, the field "Aliased Object Name", because every read attempt is run against the referenced object (e.g., user "Admin") that does not have such attribute.

This makes it rather difficult to determine, what the name and location of that Aliased Object is (e.g., in which the "Admin" user object resides).


To read the "Aliased Object Name" attribute, you can utilize the NWDirQuery control. A small routine like the one listed, will retrieve this attribute for any given alias entry:


function TForm1.GetAliasedObject(obj: NWDirLib_TLB.NWEntry): String; VAR v : Variant; i,j : Integer; QueryResults : NWQueryResults; QueryResult : NWQueryResult; begin result := ''; v := obj.Parent; if (not VarIsEmpty(v)) then try NWDirQuery1.FullName := v.FullName; NWDirQuery1.Filter := Format('Alias(CN=%s)', [obj.ShortName]); NWDirQuery1.Fields := AON; NWDirQuery1.SearchScope := qrySearchSubordinates; NWDirQuery1.SearchMode := qrySearchSynchronous; NWDirQuery1.MaximumResults := 1; NWDirQuery1.SortKeys := 'CN'; QueryResults := NWDirQuery1.Search; if QueryResults.Count>0 then begin QueryResult := QueryResults.Item[0]; v := QueryResult.FieldValue[AON]; if (not VarIsEmpty(v)) then result := String(v[0]); end; except end; end;


Usage of this sample

  • Select the tree that you want to browse
  • Select an alias object. Note that NWBrowse will not explicitly mark Alias objects as such,

but will display Aliasses with the icon of the aliased object (e.g., the user icon).

  • Once you have clicked on an Alias object, the object details list will show



This sample is based on the NW Session control v1.2 NW Directory control v2.2 NW Browser control v1.0 NW Dir Query control v1.0

Prerequisites (run-time): NetWare Client 32 Installation of the NetWare ActiveX controls

You can download Novell's latest ActiveX controls from the DeveloperNet web pages at http://developer.novell.com


Platform: Win9x / WinNT / Win2000

Compilers: Borland Delphi 4.x/5.x

Though it was not written for Delphi v1.x (16bit), it could be converted with only minor modifications.

Conversion between 32bit Delphi versions (2.x/3.x/4.x/5.x) should be possible without any (or only minimal) code changes.

General information on how to use Delphi with the NetWare SDK can be found in the HOW-TO.TXT file that can be downloaded as "How2Del.exe" from the TID and sample web site at http://developer.novell.com/support/sample.htm

DETAILED DESCRIPTION



DISCLAIMER THE ORIGIN OF THIS INFORMATION MAY BE INTERNAL OR EXTERNAL TO NOVELL. NOVELL MAKES EVERY EFFORT WITHIN ITS MEANS TO VERIFY THIS INFORMATION. HOWEVER, THE INFORMATION PROVIDED IN THIS DOCUMENT IS FOR YOUR INFORMATION ONLY. NOVELL MAKES NO EXPLICIT OR IMPLIED CLAIMS TO THE VALIDITY OF THIS INFORMATION.


Self-Extracting File Name: DXALINFO.EXE

Files Included: Size Date Time

DXALINFO.TXT (this file) ALIASINF.DPR 188 6-8-01 4:41 AM ALIASINF.DOF 1133 6-8-01 4:41 AM ALIASINF.CFG 445 6-8-01 4:41 AM ALIASINF.EXE 386560 6-8-01 4:41 AM ALIASINF.RES 876 6-8-01 4:41 AM READ.ME 3545 6-8-01 4:41 AM UNIT1.DFM 2397 6-8-01 4:41 AM UNIT1.PAS 8838 6-8-01 4:41 AM DXALINFO.MSG 3530 6-8-01 4:41 AM

dxalinfo.exe

dxalinfo.exe233.5 K2005-04-06

--devsup

Novell® Making IT Work As One

© 2008 Novell, Inc. All Rights Reserved.