小编Ada*_*ter的帖子

Python中的NTLM身份验证

我正在尝试使用python从Windows 7在IIS(Windows Server 2003)上实现NTLM身份验证.LAN Manager身份验证级别:仅发送NTLM响应.
客户端计算机和服务器位于同一个域中.
域控制器(AD)位于另一台服务器上(也运行Windows Server 2003).

我收到401.1 - 未经授权:由于凭据无效,访问被拒绝.你能帮我找出这个代码有什么问题和/或向我展示解决这个问题的其他可能方向(使用NTLM或Kerberos)吗?

import sys, httplib, base64, string
import urllib2
import win32api
import sspi 
import pywintypes
import socket

class WindoewNtlmMessageGenerator:
    def __init__(self,user=None):
        import win32api,sspi
        if not user:
            user = win32api.GetUserName()
        self.sspi_client = sspi.ClientAuth("NTLM",user)   

    def create_auth_req(self):
        import pywintypes
        output_buffer = None
        error_msg = None
        try:
            error_msg, output_buffer = self.sspi_client.authorize(None)            
        except pywintypes.error:
            return None
        auth_req = output_buffer[0].Buffer
        auth_req = base64.encodestring(auth_req)
        auth_req = string.replace(auth_req,'\012','')
        return auth_req 

    def create_challenge_response(self,challenge):
        import pywintypes
        output_buffer = None
        input_buffer …
Run Code Online (Sandbox Code Playgroud)

python authentication ntlm

19
推荐指数
2
解决办法
2万
查看次数

如何根据最佳实践在C#4中创建异步方法?

请考虑以下代码段:

public static Task<string> FetchAsync()
{
    string url = "http://www.example.com", message = "Hello World!";

    var request = (HttpWebRequest)WebRequest.Create(url);
    request.Method = WebRequestMethods.Http.Post;

    return Task.Factory.FromAsync<Stream>(request.BeginGetRequestStream, request.EndGetRequestStream, null)
        .ContinueWith(t =>
        {
            var stream = t.Result;
            var data = Encoding.ASCII.GetBytes(message);
            Task.Factory.FromAsync(stream.BeginWrite, stream.EndWrite, data, 0, data.Length, null, TaskCreationOptions.AttachedToParent)
                .ContinueWith(t2 => { stream.Close(); });
        })
        .ContinueWith<string>(t =>
        {
            var t1 =
                Task.Factory.FromAsync<WebResponse>(request.BeginGetResponse, request.EndGetResponse, null)
                .ContinueWith<string>(t2 =>
                {
                    var response = (HttpWebResponse)t2.Result;
                    var stream = response.GetResponseStream();
                    var buffer = new byte[response.ContentLength > 0 ? response.ContentLength : 0x100000]; …
Run Code Online (Sandbox Code Playgroud)

c# parallel-processing task

14
推荐指数
1
解决办法
8672
查看次数

交叉编译时,Golang 无法在 x86_64 机器上链接 aarch64/arm64 二进制文件

我正在尝试为 x86_64 桌面上的 aarch64 机器交叉编译https://github.com/joohoi/acme-dns 。

\n
$ CC=aarch64-linux-gnu-gcc GOOS=linux GOARCH=arm64 CGO_ENABLED=1 go build -v -ldflags="-extld=$CC"\n# github.com/mattn/go-sqlite3\nsqlite3-binding.c: In function \xe2\x80\x98sqlite3SelectNew\xe2\x80\x99:\nsqlite3-binding.c:125322:10: warning: function may return address of local variable [-Wreturn-local-addr]\n125322 |   return pNew;\n       |          ^~~~\nsqlite3-binding.c:125282:10: note: declared here\n125282 |   Select standin;\n       |          ^~~~~~~\n# github.com/joohoi/acme-dns\n/usr/lib/go-1.15/pkg/tool/linux_amd64/link: running gcc failed: exit status 1\n/usr/bin/ld: /tmp/go-link-266874795/go.o: Relocations in generic ELF (EM: 183)\n/usr/bin/ld: /tmp/go-link-266874795/go.o: Relocations in generic ELF (EM: 183)\n/usr/bin/ld: /tmp/go-link-266874795/go.o: Relocations in generic ELF (EM: 183)\n/usr/bin/ld: /tmp/go-link-266874795/go.o: Relocations in generic ELF (EM: 183)\n/usr/bin/ld: /tmp/go-link-266874795/go.o: Relocations …
Run Code Online (Sandbox Code Playgroud)

cross-compiling go cgo

8
推荐指数
1
解决办法
2576
查看次数

为什么零字节的app.config文件会导致一个非常奇怪的错误?

错误

文件的卷已经外部更改,因此打开的文件不再有效.

这是因为你有一个零字节的app.config.该错误似乎来自Windows - 即使WinDBG也不会启动它.

我知道有一个零字节app.config是完全无效的,但是导致这个错误的原因是什么,它来自何处以及为什么会发生?

c# app-config console-application

7
推荐指数
1
解决办法
699
查看次数

Android - Google Talk意图

我正在开发一个Android应用程序,其中显示Google Talk联系人的状态 - 这很好用.

我不确定使用默认的Talk应用程序打开聊天窗口应该调用哪个意图.

  • 我如何知道可以拨打哪些Google Talk意图?
  • 我怎么知道一般可以调用哪些意图?

我无法使用以下代码:

Uri imUri = new
Uri.Builder().scheme("imto").authority("skype)").appendPath("apactple").build();             
Intent intent = new Intent(Intent.ACTION_SENDTO, imUri); 
this.startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

android google-talk android-intent

3
推荐指数
1
解决办法
2992
查看次数

检测是否存在IDLE /如何判断__file__是否未设置

我有一个需要使用的脚本,__file__所以我了解到IDLE没有设置它.我的脚本有没有办法可以检测到IDLE的存在?

python python-idle

2
推荐指数
1
解决办法
696
查看次数

如何使我的控制台应用程序在成功运行后自动重启?

在用户选择选项后,如何使此程序继续运行?这是我到目前为止的代码.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace calculator_extended
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Press A for addition");
            Console.WriteLine("Press S for subtraction");
            Console.WriteLine("Press M for Multiplication");
            Console.WriteLine("Press D for Divide");

            char c = Convert.ToChar(Console.ReadLine());

            int a = Convert.ToInt32(Console.ReadLine());
            int b = Convert.ToInt32(Console.ReadLine());

            switch (c)
            {
                case 'A':
                case 'a':
                    {
                        int d = add(a, b);
                        Console.WriteLine(d);
                        break;


                    }


                case 'S':
                case 's':
                    {
                        int d = sub(a, b);
                        Console.WriteLine(d);
                        break;
                    }

                case 'M':
                case …
Run Code Online (Sandbox Code Playgroud)

c# function calculator console-application

0
推荐指数
1
解决办法
8140
查看次数