[ Pobierz całość w formacie PDF ]
.You can count the number of values, set a specific propertyvalue, or set the values for the entire collection.Methods help you perform all of theusual collection tasks, including counting the number of items and working with aspecific item.Other methods enable you to add, remove, insert, or copy permissions. ResultPropertyCollection Enables you to examine the properties for a SearchResultobject.You can count the number of properties, obtain a list of property values, obtain alist of property names, or extract the value of a single property.ResultPropertyValueCollection Enables you to examine the property values for aSearchResult object.You can count the number of items in the collection and work withspecific items.Methods enable you to perform specific tasks such as copying thecollection to an array or determining if the collection contains a specific property.SchemaNameCollection Contains a list of schema names that you can use with theSchemaFilter property of the DirectoryEntry object.You can count the number of itemsin the collection and work with specific items.Methods help you perform all of the usualcollection tasks, including counting the number of items and working with a specificitem.Other methods enable you to add, remove, insert, or copy permissions.SearchResult Contains the results of using a DirectorySearcher object to look forspecific Active Directory entries.The SearchResult object contains an entire ActiveDirectory node, beginning with the location of the first object found.SearchResultCollection Contains a collection of SearchResult objects.You canobtain a count of the of the SearchResult objects, obtain a handle to theIDirectorySearch::ExecuteSearch interface, work with a specific item, or obtain a listof properties used for the search.Methods enable you to perform specific tasks, suchas copying the collection to an array or determining if the collection contains a specificSearchResult object.SortOption Determines how Windows XP sorts the results of a search.You canspecify both the search direction and search property.As you can see, you can perform most tasks using managed code.In the few cases whereyou need to perform a task using the COM interfaces, you can obtain a copy of the objectusing built-in method calls (see DirectoryEntry as an example).Of course, several issuesbesides ease of access remain.One of the most important issues is thread safety animportant consideration in a distributed application.Generally, you ll find that public staticclass members are thread-safe, while instance members aren t.This limitation means youmust use class members carefully and take steps to ensure method calls occur in a thread-safe manner.Writing a COM+ Application that Relies on Active DirectoryThis section provides you with one example of how to use Active Directory to track users onthe road.We re going to create an application that allows a user to  punch the clock whileon the road.On the server, we ll create a component that runs all of the time looking for requests fromusers on the road.When a user activates the application, the component will store the timevalues within Active Directory.In this way, a manager can keep track of how much timeemployees on the road are spending performing certain tasks that require a login to thesystem.This type of application has many uses; I ve chosen to implement a simpler exampleof something that could provide a lot of value to a company.The following sections will helpyou design, build, and test both a client side application and a server side component.Creating the ComponentThe first thing we need to do to create this application is design a component that willreceive input from the client application on the user s machine.This component will interactwith Active Directory by looking for the user s name and then placing text in the user s  infoor Note entry.The user s Note entry appears on the Telephones tab of the User Propertiesdialog box. In the following sections, we ll create a component shell, add two methods to it, and thensome code to perform the required interactions.We ll need two different methods for thisexample.The first will add new login entries, while the second will clear all of the entriesafter the network administrator has viewed them or the user has arrived home.Creating the Component ShellBegin by creating an ATL Project.I ve given the example project a name of UserADLog, butyou can use any name you d like.The following procedure will help you create thecomponent shell required for this example.1.Create the new ATL Project.Select Application Settings.You ll see the ApplicationSettings dialog box shown here.2.Clear the Attributed options.(We ll discuss how to use attributed programmingtechniques in Chapter 13.) This example shows how to work with Active Directorydirectly, and attributed programming will hide some details.In addition, you can tmerge proxy and stub code or use MFC when working with attributes.3.Check the  Allow merging of proxy/stub code and  Support MFC options.Since this isgoing to be a COM+ application, we ll use the Dynamic Link Library (DLL) servertype.4.Check Support COM+ 1.Visual Studio.NET will support COM+ 1.5, but this supportwill appear only on Windows XP.Most of the applications this book targets will needto run on both Windows 2000 and Windows XP, so we ll use COM+ 1.0 throughout.5.Click Finish.Visual C++ will create the new component shell for you.At this point, we llneed to add a new ATL object that will contain the code that the client application willcall later.6.Right-click the UserADLog folder found on the Class View tab, then choose Add | AddClass from the context menu.You ll see the Add Class dialog box.7.Highlight the Simple Object option, then click Open.You ll see the ATL Simple ObjectWizard dialog box shown here. 8.Type ADLogEntry in the Short Name field.Visual C++ will automatically fill in the otherfield values for you.9.Click the Options tab.Check No for Aggregation and then click OK.Visual C++ willcreate the new class for you.10 [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • higrostat.htw.pl
  •