From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,87e4cff27c09752d X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.213.68 with SMTP id nq4mr4731723pbc.2.1329425729810; Thu, 16 Feb 2012 12:55:29 -0800 (PST) Path: wr5ni33110pbc.0!nntp.google.com!news1.google.com!eweka.nl!lightspeed.eweka.nl!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!news.mixmin.net!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Windows LDAP group-user checking in Ada 95 Date: Thu, 16 Feb 2012 21:55:22 +0100 Organization: cbb software GmbH Message-ID: <1e2tjheyqye1a.1msarege98c4g$.dlg@40tude.net> References: <29156956.1684.1329424734114.JavaMail.geo-discussion-forums@yndy9> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: WkJcN1DtAlzS9oQn+70EHw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-02-16T21:55:22+01:00 List-Id: On Thu, 16 Feb 2012 12:38:54 -0800 (PST), Rego, P. wrote: > For getting the username, I have the function (in Ada 95): > > function GetUsername return String is > function GetEnv (Variable : String) return Interfaces.C.Strings.chars_ptr; > pragma Import (C, GetEnv, "getenv"); > > Command : constant String := "USERNAME"; > Answer_Ptr : constant Interfaces.C.Strings.chars_ptr := GetEnv (Command); > Answer : constant String := Interfaces.C.Strings.Value (Answer_Ptr); > begin > return Answer; > end GetUsername; This is wrong, you cannot pass String to a C program. Then the user name variable is named USER. with Interfaces.C.Strings; use Interfaces.C; use Interfaces.C.Strings; function GetUsername return String is -- Constraint_Error when undefined function GetEnv (Variable : char_array) return chars_ptr; pragma Import (C, GetEnv, "getenv"); begin return Value (GetEnv (To_C ("USER"))); end GetUsername; But you don't need that because there already exist the package Ada.Environment_Variables. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de