Hey guys, have a WEIRD arsed problem with Delphi 4 here....   In the below 
code, the moment checkNTSecurity() hits its begin, it jumps into the NTUser 
function, which is causing problems on some systems connected to Novel.

Does anyone have any idea why the NTUser function would be getting called 
automatically?  It's taxing my mind and I can't seem to spot anything that 
would be causing it....

Mark


procedure something...
begin
  checkNTSecurity(...);
end;


function checkNTsecurity(uid, pwd, dbms, svr, dbname : string; ntu: string 
= '') : boolean;
var
   db : TDatabase;
   qry : TQuery;
begin
   result := true;    // This function returns true if login prompt IS 
required
   dbms := uppercase(copy(dbms,1,3));
   if (uid <> '') and (pwd <> '') and (svr <> '') and (dbms <> '') and 
(dbname <> '') then
   try
      try
         db := TDatabase.create(nil);
         db.LoginPrompt := false;
         db.databasename := 'tmp';
         qry := TQuery.create(nil);
         qry.DatabaseName := 'tmp';
         if dbms = 'MSS' then
            db.DriverName := 'MSSQL'
         else if dbms = 'SYB' then
            db.DriverName := 'SYBASE'
         else if (dbms = 'O84')
              or (dbms = 'ORA') then
            db.DriverName := 'ORACLE';
         db.params.values['password']  := pwd;
         db.params.values['server name']    := svr;
         if db.DriverName = 'ORACLE' then
         begin
            db.params.values['user name'] := dbname;
            db.params.values['rowset size'] := '1';
         end
         else
         begin
            db.params.values['user name'] := uid;
            db.params.values['database name'] := dbname;
         end;
         db.open;

         if db.connected then
         begin
            qry.SQL.text := 'select nt_trusted from Control';
            qry.open;
            if not qry.eof then
            begin
              if uppercase(qry.fields[0].asstring) = 'Y' then
              begin
                if ntu = '' then ntu := NTUser;
                ntu := uppercase(ntu);

                qry.SQL.text := 'select nt_trusted, name, password from 
Staff where upper(name) = ''' + ntu + '''';
                qry.open;
                if not qry.eof then
                  if uppercase(qry.fields[0].asstring) = 'Y' then
                  begin
                    result := false;
                    strNTUser := qry.fieldbyname('name').asstring;
                    strNTPwd := 
Decrypt(qry.fieldbyname('password').asstring);
                  end;
              end;
            end;
         end;
      except
      end;
   finally
      db.free;
      qry.free;
   end;
end;

function NTuser : string;
var
   buffer : array [0..80] of char;
   buff_len : longword;
begin
   buff_len := 80;
   buffer[0] := #0;
   if getusername(buffer,buff_len) then
      result := buffer
   else
      result := '';
end;

-- 
There are exceptions, I'm sure, but the Windows 2000 on-line community
seems to have, in general, the moral and spiritual qualities of your
average porn site. (c) Bryan Pfaffenberger, Linux Journal, Jan 2001.
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to