0

現在の週に該当するすべての誕生日と記念日を取得しようとしています。と を使用Directory SearcherしてLDAPいます。私は初めてでLDAP、以下のコードを使用しています:

            string _path = "LDAP:";
            System.DirectoryServices.DirectoryEntry entry = new System.DirectoryServices.DirectoryEntry(_path);
            DirectorySearcher ds = new DirectorySearcher(entry);

            string month = DateTime.Now.Month.ToString();

            string day = DateTime.Today.Day + numDays.ToString();

             ds.Filter = "(&(objectClass=user)(description=" + month + "\\" + day +"))";
             SortOption option = new SortOption("description", System.DirectoryServices.SortDirection.Ascending);
             ds.Sort = option;
             DataSet dSet = new DataSet();
             DataTable dTable = new DataTable("Events");
             dTable.Columns.Add("birthday");
             foreach (System.DirectoryServices.SearchResult resEvent in ds.FindAll())
             {
                 System.DirectoryServices.DirectoryEntry de1 = resEvent.GetDirectoryEntry();
                 DataRow dRow = dTable.NewRow();
                 if (de1.Properties["description"].Value != null)
                 {
                     dRow["birthday"] = de1.Properties["description"].Value.ToString();

                     dTable.Rows.Add(dRow);

                 }
             }

             dSet.Tables.Add(dTable);
             return dSet;
4

1 に答える 1

1

イベントはユーザーのdescription属性の下に保存されていますか?

属性値がどのように見えるかについてはあまり詳しくありません。

アクセスできないc#を使用しようとしていますが、LDAPクエリから、これは機能します:(&(objectClass = user)(description = 09/15 *))

-ジム

于 2012-09-15T00:13:35.083 に答える