CまたはC++で関数が必要です(実際にはAda 95では必要ですが、プラグマのインポートは問題なく使用できます。 -gnat05
スイッチ)を使用して、ユーザーがLDAPネットワークグループに存在するかどうかを確認します。ユーザ名を取得するためのCまたはC++(またはAda 95)のWindows LDAPグループユーザーチェック
、私は私はエイダ95にインポートすることができますC関数GetEnv
、持っている:
function GetUsername return String is
function GetEnv (Variable : String) return Interfaces.C.Strings.chars_ptr;
pragma Import (C, GetEnv, "getenv");
Command : constant String := "USER" & ASCII.Nul;
Answer_Ptr : constant Interfaces.C.Strings.chars_ptr := GetEnv (Command);
Answer : constant String := Interfaces.C.Strings.Value (Answer_Ptr);
begin
return Answer;
end GetUsername;
をだから私は、CまたはC++でこのような機能Boolean Check_LDAP_Authentication (char* Username)
か何かを必要とする(またはAdaのCheck_LDAP_Authentication (Username : String) return Boolean
でも)。どうしたらいいですか?
ありがとうございます。
更新
私はエイダ95同等のものを必要なだけのことを、私は何をする必要があるか(C#/ VB.Netを使用し、System.DirectoryServices)非常によく表現How to write LDAP query to test if user is member of a group?上の記事を見つけました。
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");
}
私は運がそれに何かを持っているとは信じません。私はサバンナとAWSのコードを見ているかもしれませんが、多分私はいくつかのヒントを得るでしょう。穴のライブラリを含めることは良いアイデアではありません。ありがとうございました。 – Rego
Mac OS X Lionでコードを実行すると、適切な環境変数( 'USERNAME'ではなく' USER)が 'Dereference_Error'になります。 –
...しかし、 'Command:constant String:=" USER "&ASCII.Nul;はより良く動作するようです。しかし、まだ推奨されていません(そして、私は、あなたの実際の問題には関係ないと思います)。 –