C# 4.0 用于查询active directory以返回本周即将发生的事件的筛选器
我正在努力获取本周的所有生日和周年纪念日。我正在使用C# 4.0 用于查询active directory以返回本周即将发生的事件的筛选器,c#-4.0,sharepoint-2010,ldap,ldap-query,C# 4.0,Sharepoint 2010,Ldap,Ldap Query,我正在努力获取本周的所有生日和周年纪念日。我正在使用目录搜索器和LDAP。我是LDAP的新手,正在使用以下代码: string _path = "LDAP:"; System.DirectoryServices.DirectoryEntry entry = new System.DirectoryServices.DirectoryEntry(_path); DirectorySearcher ds = new Direct
目录搜索器
和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;
您的事件是否存储在“用户描述”属性下 没有太多关于属性值的细节 您正在尝试使用c#,我无权访问它,但可以通过LDAP查询访问它,这样做可以: (&(objectClass=user)(description=09/15*)) -吉姆