我正在使用DirectorySearcher在LDAP服务器中搜索用户条目.
DirectoryEntry de = new DirectoryEntry();
de.Path = "LDAP://myserver/OU=People,O=mycompany";
de.AuthenticationType = AuthenticationTypes.None;
DirectorySearcher deSearch = new DirectorySearcher();
deSearch.SearchRoot = de;
deSearch.Filter = "(uid=" + model.UserName + ")";
SearchResult result = deSearch.FindOne();
Run Code Online (Sandbox Code Playgroud)
我能够在结果变量中得到预期的输出.
但是,如果我尝试通过在目录条目中提供密码来验证同一用户,我总是会收到以下错误.
"用户名或密码不正确."
DirectoryEntry entry = new DirectoryEntry("LDAP://myserver/OU=People,O=mycompany", username, password);
DirectorySearcher search = new DirectorySearcher(
entry,
"(uid=" + username + ")",
new string[] { "uid" }
);
search.SearchScope = System.DirectoryServices.SearchScope.Subtree;
SearchResult found = search.FindOne(); ->>>>>this is where I get wrong credential error.
Run Code Online (Sandbox Code Playgroud)
用户名和密码适用于我要验证的用户.
任何人都可以告诉我这里我做错了什么或如何调试这个.
我有一个包含以下内容的批处理文件:
echo %~dp0
CD Arvind
echo %~dp0
Run Code Online (Sandbox Code Playgroud)
即使更改目录值后%~dp0也是如此.但是,如果我从CSharp程序运行此批处理文件,则CD%~dp0后更改的值.它现在指向新目录.以下是我使用的代码:
Directory.SetCurrentDirectory(//Dir where batch file resides);
ProcessStartInfo ProcessInfo;
Process process = new Process();
ProcessInfo = new ProcessStartInfo("mybatfile.bat");
ProcessInfo.UseShellExecute = false;
ProcessInfo.RedirectStandardOutput = true;
process = Process.Start(ProcessInfo);
process.WaitForExit();
ExitCode = process.ExitCode;
process.Close();
Run Code Online (Sandbox Code Playgroud)
为什么以不同方式执行相同脚本的输出存在差异?
我在这里想念一下吗?
我有一个要求,我必须根据输入参数使用c#(大小可以在10mb到400mb之间)下载一个zip文件.例如,下载userId = 10和year = 2012
的报告.Web 服务器接受这两个参数并返回一个zip文件.如何使用WebClient类实现此目的?
谢谢