0

datagridviewで情報を取得していません。マルチテキストボックスで試してみた場合は問題ありませんが、datagridviewでは使用できません

public String Accountlocked()
        {
            //DirectoryEntry entry = new DirectoryEntry("LDAP://Mytechnet.com");
            DirectoryEntry entry = new DirectoryEntry("LDAP://User");
            DirectorySearcher Dsearch = new DirectorySearcher(entry);



            Dsearch.Filter = "(&(&(&(&(&(objectCategory=person)(objectClass=user)>>(lockoutTime:1.2.840.113556.1.4.804:=4294967295))))))";


            using (StringWriter sw = new StringWriter())
            {

                foreach (SearchResult sResultSet in Dsearch.FindAll())
                {

                    sw.WriteLine("{0}", (GetProperty(sResultSet, "samaccountname")));
                    sw.WriteLine("{0}", (GetProperty(sResultSet, "name")));

                }
                return sw.ToString();

            }

        }

ボタン上

dataGridView1.DataSource = Accountlocked().ToList();
4

1 に答える 1

0
public DataTable Accountlocked()
        {
           //DirectoryEntry entry = new DirectoryEntry("LDAP://Mytechnet.com");
           DirectoryEntry entry = new DirectoryEntry("LDAP://User");
           DirectorySearcher Dsearch = new DirectorySearcher(entry);

           Dsearch.Filter = "(&(&(&(&(&(objectCategory=person)(objectClass=user)>>(lockoutTime:1.2.840.113556.1.4.804:=4294967295))))))";

           DataTable dt = new DataTable();
           dt.Columns.Add("AccountName");
           dt.Columns.Add("Name");
                foreach (SearchResult sResultSet in Dsearch.FindAll())
                {
                   DataRow dr = dt.NewRow();          
                   dr[0] = (GetProperty(sResultSet, "samaccountname"));
                   dr[1] = (GetProperty(sResultSet, "name"));
                   dt.Rows.Add(dr);
                }
                return dt;
            }
        }


dataGridView1.DataSource = Accountlocked();
于 2013-03-08T03:33:03.887 に答える