如何判断域中是否有"nattystyle"用户存在 域是域,局域网是局域网,切勿混淆RT,求具体代码 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 DirectoryEntry entry = new DirectoryEntry("LDAP://CN=users,DC=fabrikam,DC=com");DirectorySearcher mySearcher = new DirectorySearcher(entry);mySearcher.Filter = "(&(objectClass=user)(anr=test*))";SearchResultCollection ResEnt = mySearcher.FindAll();{// Handle results.}// Handle exceptions. if (runcmd("net user /DOMAIN").IndexOf("nattystyle") >= 0) Console.WriteLine("Has user"); else Console.WriteLine("No user");没有域环境,你试试.不行算我没说. private static string runcmd(string command) { Process p = new Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.Arguments = "/c " + command; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.CreateNoWindow = true; p.Start(); return p.StandardOutput.ReadToEnd(); } //1. add reference System.DirectoryServices...using System.DirectoryServices......public static bool DoesDomainUserExist(string username){ DirectoryEntry entry = new DirectoryEntry("LDAP://YourDomain","yourDomainUserName", "yourDomainPassword" ); DirectorySearcher searcher = new DirectorySearcher(entry); searcher.Filter = "(&(objectClass=user) (cn=" + username + "))"; SearchResultCollection results = searcher.FindAll(); return results.Count > 0;} 以前做过类似的程序,直接copy过来给你。 字符数组中数字大小判断问题?急 【散分】求教timer组件更新界面问题 如何使剪贴板 仅可以在自己的程序中使用? 生成安装包后的问题 建了一个复合控件,不知道暴露子控件方法?敬请专家解决! 有没有类似msn space中相册幻灯片一样播放图片的.net控件 CommonTransportKeys怎么用??????? C#下MSCOMM通信问题 大家看看这个问题该如何解决!!!关于自动检索的,当然要速度,速度!!!!! c#中奇怪的局部变量与事件的关系--谁能够说得清楚下面的问题 熟悉WPF的大侠请进 请问...两台电脑知道对方IP和断口,怎样实现相互通信传文件?
DirectorySearcher mySearcher = new DirectorySearcher(entry);
mySearcher.Filter = "(&(objectClass=user)(anr=test*))";
SearchResultCollection ResEnt = mySearcher.FindAll();
{
// Handle results.
}
// Handle exceptions.
Console.WriteLine("Has user");
else
Console.WriteLine("No user");没有域环境,你试试.不行算我没说. private static string runcmd(string command)
{
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments = "/c " + command;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
return p.StandardOutput.ReadToEnd();
}
using System.DirectoryServices
...
...
public static bool DoesDomainUserExist(string username)
{
DirectoryEntry entry = new DirectoryEntry("LDAP://YourDomain","yourDomainUserName", "yourDomainPassword" );
DirectorySearcher searcher = new DirectorySearcher(entry);
searcher.Filter = "(&(objectClass=user) (cn=" + username + "))";
SearchResultCollection results = searcher.FindAll();
return results.Count > 0;
}