我正在开发一个用于重置 LDAP 用户密码的网站。我无法通过 ssl 与服务器建立连接。我尝试了各种代码和身份验证类型。
这是服务器上用于与托管网站的 LDAP 连接的内容。我还使用两个 ssl 端口对其进行了测试。636 和 3269。
0 = ldap_set_option(ld, LDAP_OPT_ENCRYPT, 1)
res = ldap_bind_s(ld, NULL, &NtAuthIdentity?, NEGOTIATE (1158)); v.3
{NtAuthIdentity?: User='_ldapuser'; Pwd='unavailable';; domain = 'SJTPNOC.DOMAIN'}
Run Code Online (Sandbox Code Playgroud)
我在网站中使用以下代码
LdapConnection connection = new LdapConnection(new LdapDirectoryIdentifier("SJTP.DOMAIN",636));
connection.SessionOptions.ProtocolVersion = 3;
connection.AuthType = AuthType.Basic;
connection.Credential = new NetworkCredential("CN=user,CN=Users,DC=SJTPNOC,DC=DOMAIN", "password","CN=Users,DC=SJTPNOC,DC=DOMAIN");
connection.SessionOptions.SecureSocketLayer=true;
connection.Bind();
Run Code Online (Sandbox Code Playgroud)
出现异常“LDAP 服务器不可用”。我尝试使用 389 端口且没有 ssl 的代码,它工作正常。
请让我知道出了什么问题。
我正在开发一个地铁应用程序.我使用后台上传器上传文件,但我的问题是如何在上传后获得响应值.我这样编码:
BackgroundUploader uploader = new BackgroundUploader();
uploader.SetRequestHeader("Content-Disposition", "form-data");
uploader.SetRequestHeader("name", "userfile");
uploader.SetRequestHeader("filename", App.ViewModel.DeviceId + ".png");
uploader.SetRequestHeader("Content-Type", "multipart/form-data");
UploadOperation upload = uploader.CreateUpload(uri, file);
await upload.StartAsync();
Run Code Online (Sandbox Code Playgroud) 我发现一些非常奇怪的东西,如果我在excel和c#中使用下面的表达式,我会得到不同的结果.
(1) ^ (-12)
Run Code Online (Sandbox Code Playgroud)
Excel给出1和c#给出-11.
哪一个是对的?
我有一个PCl,我想在其中使用HttpClient进行异步调用.我编码像这样
public static async Task<string> GetRequest(string url)
{
var httpClient = new HttpClient() { MaxResponseContentBufferSize = int.MaxValue };
HttpResponseMessage response = await httpClient.GetAsync(url);
return response.Content.ReadAsStringAsync().Result;
}
Run Code Online (Sandbox Code Playgroud)
但等待显示错误"无法等待System.net.http.httpresponsemessage"之类的消息.
如果我使用这样的代码比一切顺利但不是异步方式
public static string GetRequest(string url)
{
var httpClient = new HttpClient() { MaxResponseContentBufferSize = int.MaxValue };
HttpResponseMessage response = httpClient.GetAsync(url).Result;
return response.Content.ReadAsStringAsync().Result;
}
Run Code Online (Sandbox Code Playgroud)
我只是希望这个方法以异步方式执行.
这是屏幕截图:
