var
  Buffer : Array[0..255] of char;
 Size : DWORD;
begin
  GetUserName(Buffer, Size);
  ShowMessage('The username is "'+StrPas(Buffer)+'"');
end;

If I run the bit of code above in Delphi I get the current user account that
I am logged in as. Say "Administrator"

If I move that code to a COM Control; below is my code

var
 Buffer : Array[0..255] of char;
 Size : DWORD;
begin
  GetUserName(Buffer, Size);
  m_scriptContext.Response.Write('<P><P>This script is running under the
"'+StrPas(Buffer)+'" account</P><P>');
end;

I then run it from a ASP Page I get an output of

This script is running under the "hj4e" account

Any ideas? I do not have an account called "hj4e", I would expect it to use
"INET_ADROCK" since adrock is the server's name.

If I set the DELPHI Com control to run under MTS and to force it to use a
specific user account say ADMINISTRATOR, it still returns the same output.

This script is running under the "hj4e" account

I did the same running test uses a VB COM Control.

     Public Property Get UserName() As Variant
          Dim sBuffer As String
          Dim lSize As Long
          sBuffer = Space$(255)
          lSize = Len(sBuffer)
          Call GetUserName(sBuffer, lSize)
          UserName = "The username that this component is running in is " +
Left$(sBuffer, lSize)
     End Property

The username that this component is running in is "INET_ADROCK"

And when I put it into MTS and force it to use the ADMINISTRATOR account I
get

The username that this component is running in is "Administrator"

How come I do not get the same from the Delphi COM Control?

Chris

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to