Isn't it kind of sad though that Microsoft still doesn't provide adequate admin 
tool almost a decade after that bloody ADS has been released.. still such a 
poor imitation of Novell's NDS. It's still basically LAN Manager under the hood.

Dave

Sean Roberts <[EMAIL PROTECTED]> wrote:                               That's an 
excellent question, Dave.
  
 The reason I want to use Delphi is that I already use it to perform a great 
number of admin tasks here at the company.
  
 I regularly provide reports (data gathered and compiled using a Delphi app) 
for statistics like days-since-reboot, OU name, hardware models, free disk 
space, etc.
  
 In this particular case, we have a 120 day threshold for which, if machines 
have not logged in to the domain, we move them to an OU from which the accounts 
will be deleted.
  
 I plan to use Delphi to track communications/warnings sent to the user, etc. 
so I can know when it's safe (and I'm officially allowed) to delete machines 
from the domain or at least move the accounts to diferent OUs.
  
 That's why I want to move them in Delphi.
  
 I already GET OU information by using the code below (posted in case anyone 
else needs to get AD info usign Delphi).
  
 By the way, if you're trying to access AD information using ADO, you HAVE to 
use the TADODataSet.
  
 That's the only way to get past the 1000 record limit of ODBC's AD connection 
(by passing the Page Size property, which you can't do using a TADOTable or 
TADOQuery).
  
       ADODataSet := TADODataSet.Create(nil);
      ADOCommand := TADOCommand.Create(nil);
      ADOCommand.Connection := ADOConnection3;
      ADOCommand.CommandText := 'SELECT CN,ADsPath from ' + 
QuotedStr('LDAP://DC=NA,DC=XXX,DC=Int') + ' WHERE objectClass = ' + 
QuotedStr('computer') + ' ORDER BY CN';
      ADOCommand.Properties.Item['Page Size'].Value := 10;
      ADODataSet.Recordset := ADOCommand.Execute;
      ADODataSet.First;
       while NOT ADODataSet.Eof do
        begin
           Application.ProcessMessages;
          If StopFlag
          then Break;
           //Update status bar
          Application.ProcessMessages;
          ProgressBar1.Position := Trunc(ADODataSet.RecNo / 
ADODataSet.RecordCount * 100);
          StatusBar1.Update;
           ComputerName := ADODataSet.FieldByName('CN').AsString;
          DataSource := 'A';
          UserName := '';
          ScanDate := '';
          LocationName := '';
          TimeZone := '';
          LastBootDate := '';
          DeviceDescription := '';
          VendorName := '';
          VendorModel := '';
          VendorSerial := '';
          AssetTag := '';
          ImageVersion := '';
          ADsPath := ADODataSet.FieldByName('AdsPath').AsString;
          OU := SimplifyOUName(ADsPath);
          OperatingSystem := '';
          Processor := '';
          RamSize := '';
          HardDriveSize := '';
          DriveSpaceFree := '';
          NetworkAdapter := '';
          MacAddress := '';
          IPAddress := '';
          SubnetMask := '';
          VideoAdapter := '';
          OpticalDrive := '';
          PointingDevice := '';
          SoundDevice := '';
          Modem := '';
          Monitor := '';
          Keyboard := '';
          BiosVersion := '';
           Application.ProcessMessages;
           if Pos('accounts - computers',LowerCase(OU)) > 0
          then UpdateDataSource(ComputerName,
                       DataSource,
                       UserName,
                       ScanDate,
                       LocationName,
                       TimeZone,
                       LastBootDate,
                       DeviceDescription,
                       VendorName,
                       VendorModel,
                       VendorSerial,
                       AssetTag,
                       ImageVersion,
                       OU,
                       OperatingSystem,
                       Processor,
                       RamSize,
                       HardDriveSize,
                       DriveSpaceFree,
                       NetworkAdapter,
                       MacAddress,
                       IPAddress,
                       SubnetMask,
                       VideoAdapter,
                       OpticalDrive,
                       PointingDevice,
                       SoundDevice,
                       Modem,
                       Monitor,
                       Keyboard,
                       BiosVersion,
                       ADsPath);
 
          ADODataSet.Next;
      end;
       if Assigned(ADOCommand) then FreeAndnIl(ADOCommand);
      if Assigned(ADODataSet) then FreeAndnil(ADODataSet);


XFX nForce 680i LT SLI Socket 775 | Intel Core 2 Duo E6750 OC:1600 FSB @ 3.2 
MHz | 2 x OCZ SLI 1024MB PC6400 DDR2 800MHz| XION 600w PSU | CM Stacker 200 
ATX/BTX Case | EVGA GeForce 8800 GTS 512 | WD SATA 74 GB Raptor (boot,system), 
WD SATA 500 GB (storage) | Windows XP Pro, SP2 | Patient and supportive 
significant other


 
 
---------------------------------
 To: advanced_delphi@yahoogroups.com
From: [EMAIL PROTECTED]
Date: Fri, 11 Apr 2008 08:18:54 -0700
Subject: Re: [advanced_delphi] Moving machine accounts in Active Directory

        I'm just curious: Why wouldn't you use the supplied Microsoft tools for 
accomplishing this? That sounds like an unbelievably trivial operation to 
accomplish  using NWAdmin in Novell's NDS.

   Search for some components that encapsulate the API, or I think JEDI has a 
unit that encapsulates that functionality. 

    I found Colin Wilson's units for Active Directory in the few minutes I 
spent searching. JEDI is rather poorly documented (still!):

http://www.wilsonc.demon.co.uk/delphi.htm

Dave


Sean Roberts <[EMAIL PROTECTED]> wrote:    Greetings to all!

I've been working with Delphi for quite a while, but I've never had to 
use it to access Active Directory.

Part of my job as a Desktop Administrator is to move machine accounts 
around in our AD OU structure.

Does anyone have code for how to move a machine account from one OU to 
another?

If someone can point me in the right direction, I would be very 
appreciative.

Thanks in advance,

- Sean Roberts
[EMAIL PROTECTED]




 __________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


       



---------------------------------
Get in touch in an instant. Get Windows Live Messenger now. 
     
                                       

 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to