本帖最后由 hya0114145 于 2011-01-05 16:07:01 编辑

解决方案 »

  1.   

    但是装IIS的电脑和装域的电脑不是一台电脑
    网站是如何发送请求给装域的电脑..
      

  2.   

    这是另一个问题..而且你需要一个有权限的用户权限来判断输入的用户是否有权限..因为网站都是匿名访问..
    客户又不想windows集成验证..所有才想到把信息发送到安装域的电脑上来判断
    所有就产生一个问题..asp.net是如何发送信息给安装域的电脑  
    他说通过ldap的协议什么的..
      

  3.   


    IIS可以调用域服务器进行验证using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Security;
    using System.DirectoryServices;
    using System.Text;string domain="你的域名";
    string username="域用户名";
    string pwd = "口令";
    string _path="LDAP://"+domain;
    string domainAndUsername = domain + @"\" + username;
                DirectoryEntry entry = new DirectoryEntry(_path, domainAndUsername, pwd);
                DataTable dt = new DataTable();            try
                {
                    //Bind to the native AdsObject to force authentication.
                    object obj = entry.NativeObject;                DirectorySearcher search = new DirectorySearcher(entry);                search.Filter = "(SAMAccountName=" + username + ")";
                    //search.PropertiesToLoad.Add("cn");
                    search.PropertiesToLoad.AddRange(new String[] { "cn", "sAMAccountName", "displayName", "department", "title", "mail", "telephoneNumber" });
                    SearchResult result = search.FindOne();                string a = (string)result.Properties["cn"][0];
                    string b = (string)result.Properties["sAMAccountName"][0];
                    string c = (string)result.Properties["displayName"][0];
                    //string d = (string)result.Properties["department"][0];
                    string e = (string)result.Properties["title"][0];
                    string f = (string)result.Properties["mail"][0];
                    string g = (string)result.Properties["telephoneNumber"][0];
                    dt.Columns.Add("Login", typeof(string));
                    dt.Columns.Add("FullName", typeof(string));
                    dt.Columns.Add("Department", typeof(string));
                    dt.Columns.Add("Duty", typeof(string));
                    dt.Columns.Add("Email", typeof(string));
                    dt.Columns.Add("Phone", typeof(string));                DataRow dr = dt.NewRow();
                    dr["Login"] = b;
                    dr["FullName"] = c;
                    dr["Department"] = "";
                    dr["Duty"] = e;
                    dr["Email"] = f;
                    dr["Phone"] = g;
                    dt.Rows.Add(dr);                if (null == result)
                    {
                        //return false;
                        return dt;
                    }                //Update the new path to the user in the directory.
                    _path = result.Path;
                    //result.GetDirectoryEntry(entry).Properties["cn"].Values;
                    //_filterAttribute= (string)result.Properties["cn"][0];
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }            if(dt.Rows.Count>0)
                {
                      //是域用户
                }
                else
                {
                      //不是域用户
                  }
                
    //dt的列有可能会是空(你不需要这么多列),你自己注意下,因为建立域账号的时候不一定信息都填全了
      

  4.   

    string _path="LDAP://"+domain;
    string domainAndUsername = domain + @"\" + username;
    DirectoryEntry entry = new DirectoryEntry(_path, domainAndUsername, pwd);WinNT    *      连接到计算机上的组。例如“WinNT://<域名>/<计算机名>/<组名>”。如果是连接到本地计算机,则为“WinNT://<计算机名>/<组名>”。
        *      连接到计算机上的用户。例如“WinNT://<域名>/<计算机名>/<用户名>”。如果是连接到本地计算机,则为“WinNT://<计算机名>/<用户名>”。
        *      连接到计算机上的服务。例如“WinNT://<域名>/<计算机名>/<服务名>”。如果是连接到本地计算机,则为“WinNT://<计算机名>/<服务名>”。
        *      发现网络上的所有域。例如,“WinNT:”通过枚举此项的子级可以找到这些域。LDAP    *      连接到域中的组。例如“LDAP://CN=<组名>, CN =<用户>, DC=<域组件>, DC=<域组件>,...”。
        *      连接到域中的用户。例如“LDAP://CN=<完整用户名>, CN=<用户>, DC=<域组件>, DC=<域组件>,...”。
        *      连接到域中的计算机。例如“LDAP://CN=<计算机名>, CN=<计算机>, DC=<域组件>, DC=<域组件>,...”。上面的代码不对吧...LDAP:后面的字符串不对