* Windows LDAP group-user checking in Ada 95
@ 2012-02-16 20:38 Rego, P.
2012-02-16 20:55 ` Dmitry A. Kazakov
2012-02-21 16:51 ` Pascal Obry
0 siblings, 2 replies; 8+ messages in thread
From: Rego, P. @ 2012-02-16 20:38 UTC (permalink / raw)
I need a function in Ada 95 (or in C, which a pragma import can be used with no problem - I must not use the -gnat05 switch) to check if a user is present in a LDAP network group.
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;
So I need a function Check_LDAP_Authentication (Username : String) return Boolean. How can I do it?
In stackoverflow someone suggested AWS or Savanna, but I think include them in the app could also include an unnecessary complexity to the system, because I don't have to use other network features, just a network group checking.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Windows LDAP group-user checking in Ada 95
2012-02-16 20:38 Windows LDAP group-user checking in Ada 95 Rego, P.
@ 2012-02-16 20:55 ` Dmitry A. Kazakov
2012-02-21 14:34 ` Rego, P.
2012-02-21 16:51 ` Pascal Obry
1 sibling, 1 reply; 8+ messages in thread
From: Dmitry A. Kazakov @ 2012-02-16 20:55 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Windows LDAP group-user checking in Ada 95
2012-02-16 20:38 Windows LDAP group-user checking in Ada 95 Rego, P.
2012-02-16 20:55 ` Dmitry A. Kazakov
@ 2012-02-21 16:51 ` Pascal Obry
2012-02-23 12:58 ` Rego, P.
1 sibling, 1 reply; 8+ messages in thread
From: Pascal Obry @ 2012-02-21 16:51 UTC (permalink / raw)
To: Rego, P.
Le 16/02/2012 21:38, Rego, P. a �crit :
> So I need a function Check_LDAP_Authentication (Username : String)
> return Boolean. How can I do it?
Using AWS.LDAP.* API?
--
--|------------------------------------------------------
--| Pascal Obry Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--| http://www.obry.net - http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Windows LDAP group-user checking in Ada 95
2012-02-21 16:51 ` Pascal Obry
@ 2012-02-23 12:58 ` Rego, P.
2012-02-23 17:44 ` Pascal Obry
0 siblings, 1 reply; 8+ messages in thread
From: Rego, P. @ 2012-02-23 12:58 UTC (permalink / raw)
Cc: Rego, P.
Pascal, I looked for in AWS, but didn't find anything (but I've never used AWS before, so maybe I have missed something).
What I want to do is the equivalent in C#
DirectoryEntry rootEntry = new DirectoryEntry("LDAP://dc=yourcompany,dc=com");
DirectorySearcher srch = new DirectorySearcher(rootEntry);
srch.SearchScope = SearchScope.Subtree;
srch.Filter = "(&(objectcategory=user)(sAMAccountName=yourusername)(memberof=CN=yourgroup,OU=yourOU,DC=yourcompany,DC=com))";
SearchResultCollection res = srch.FindAll();
if(res == null || res.Count <= 0)
{
Console.WriteLine("This user is *NOT* member of that group");
}
else
{
Console.WriteLine("This user is INDEED a member of that group");
}
but in Ada 95.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Windows LDAP group-user checking in Ada 95
2012-02-23 12:58 ` Rego, P.
@ 2012-02-23 17:44 ` Pascal Obry
0 siblings, 0 replies; 8+ messages in thread
From: Pascal Obry @ 2012-02-23 17:44 UTC (permalink / raw)
To: Rego, P.
Rego,
> Pascal, I looked for in AWS, but didn't find anything (but I've never
> used AWS before, so maybe I have missed something).
>
> What I want to do is the equivalent in C#
[code removed]
> but in Ada 95.
Looks like this is not LDAP but some C# API for doing LDAP. I would
start from a C LDAP example. This should translate easily using the
AWS.LDAP.Thin API.
Pascal.
--
--|------------------------------------------------------
--| Pascal Obry Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--| http://www.obry.net - http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-02-23 17:44 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-16 20:38 Windows LDAP group-user checking in Ada 95 Rego, P.
2012-02-16 20:55 ` Dmitry A. Kazakov
2012-02-21 14:34 ` Rego, P.
2012-02-21 14:57 ` Dmitry A. Kazakov
2012-02-23 12:43 ` Rego, P.
2012-02-21 16:51 ` Pascal Obry
2012-02-23 12:58 ` Rego, P.
2012-02-23 17:44 ` Pascal Obry
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox