Board index » delphi » Novell usernames in Delphi

Novell usernames in Delphi

Does anyone know how to get the logged in user's Novell username from a
Delphi program?

Thanks,

David K.

 

Re:Novell usernames in Delphi


Hi David,  
This function has been giving me the Novell login ID.  
I'm not sure if you want this ID, or link their ID to the full user name, which I
haven't tried to do-- I think you'd need either their ODBC driver or some Novell API
function call.  You can check their web site for more info, I believe it is
developer.novell.com.

Hope this helps,  Brian

function FetchWNetGetUser: String;
var
    localName : array[0..255] of char;
    userName : array[0..255] of char;
    rc : Integer;
    len : Integer;
begin
    FillChar(localname,sizeof(localName), #00);
    FillChar(userName, sizeof(userName), #00);
    len := 255-1;
    rc := WNetGetUser(localName,userName,len);
    if ( rc <> 0 ) then
       ShowMessage('wnetgetuser error #' + inttostr(rc));
    //else
    //   ShowMessage(Format( 'Local Name = [%s], User Name =
[%s]',[strpas(localName),strpas(userName)] ));
    if rc = 0 then
       result := strpas(userName)
    else
       result := '????';
end;

Quote
David Kroll wrote:
> Does anyone know how to get the logged in user's Novell username from a
> Delphi program?

Re:Novell usernames in Delphi


There are many third-party components that perform network
functionality. That notwithstanding, if is generally the case that in
a Novell login script, the USERNAME environment variable is set to the
login name. You can access DOS environment variables through Delphi.

Woody

Quote
David Kroll wrote in message <361A3752.682ED...@hotmail.com>...
>Does anyone know how to get the logged in user's Novell username from
a
>Delphi program?

>Thanks,

>David K.

Re:Novell usernames in Delphi


There's a BDE function called  "DbiGetNetUserName". You have to include
"bde" in your "uses" statement and do something like the following:

           var
           cpNetName:  Array[0..48] of char;
           iResult:  DBIResult;
           begin
           iResult := DbiGetNetUserName (cpNetName);
           end;

I haven't tried it, but this (minus error checking) is from "Delphi
Database Development" M&T Books, by Ted Blue, John Kaster, Greg Lief and
Loren Scott, 1996. A terrific reference for database programming in Delphi.

Hope this is of use.

Quote
David Kroll wrote:
> Does anyone know how to get the logged in user's Novell username from a
> Delphi program?

> Thanks,

> David K.

Re:Novell usernames in Delphi


See DbiGetNetUserName in the BDE API help file.  This will get the username
for any network, not just Novell.

--
Bill Todd
(Sorry but TeamB cannot answer questions received via email)
(Remove nospam from my email address to contact me for any other reason)

Re:Novell usernames in Delphi


John,

Quote
>There's a BDE function called  "DbiGetNetUserName". You have to include
>"bde" in your "uses" statement and do something like the following:

>           var
>           cpNetName:  Array[0..48] of char;
>           iResult:  DBIResult;
>           begin
>           iResult := DbiGetNetUserName (cpNetName);
>           end;

>I haven't tried it, but this (minus error checking) is from "Delphi
>Database Development" M&T Books, by Ted Blue, John Kaster, Greg Lief and
>Loren Scott, 1996. A terrific reference for database programming in Delphi.

Thanks for the kind words.  Nice to see it crop up every once in a while.  FWIW,
the code did work when I tested it with Delphi 2 back when I wrote that chapter.

John Kaster, Enterprise Product Manager
Please post MIDAS-related messages in inprise.public.midas

Other Threads