如何在iOS中发送NTLM请求 [英] how to send NTLM request in iOS

查看:110
本文介绍了如何在iOS中发送NTLM请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用json(NSJSONSerialization)和NSURL进行服务器客户端通信。直到现在它工作正常,但现在NTLM安全性已在服务器上实现。

I was using json(NSJSONSerialization) and NSURL for server client communication. Till now it was working fine but now NTLM security has been implemented on server.

有人能告诉我如何在iOS中使用NTLM发送请求吗?

Can anyone tell me how to send request with NTLM in iOS ?

谢谢

推荐答案

此代码会有所帮助

NSMutableString *nodeContent = [[NSMutableString alloc]init];

    NSString *soapFormat = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
                            "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
                            "<soap:Body>\n"
                            "<GetListCollection xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\" />\n"
                            "</soap:Body>\n"
                            "</soap:Envelope>\n"];



    NSLog(@"The request format is %@",soapFormat);

    NSURL *locationOfWebService = [NSURL URLWithString:@"http://localhost/_vti_bin/lists.asmx"];

    NSLog(@"web url = %@",locationOfWebService);

    NSMutableURLRequest *theRequest = [[NSMutableURLRequest alloc]initWithURL:locationOfWebService];

    NSString *msgLength = [NSString stringWithFormat:@"%d",[soapFormat length]];


    [theRequest addValue:@"text/xml" forHTTPHeaderField:@"Content-Type"];
    [theRequest addValue:@"http://schemas.microsoft.com/sharepoint/soap/GetListCollection" forHTTPHeaderField:@"SOAPAction"];
    [theRequest addValue:msgLength forHTTPHeaderField:@"Content-Length"];
    [theRequest setHTTPMethod:@"POST"];
    //the below encoding is used to send data over the net
    [theRequest setHTTPBody:[soapFormat dataUsingEncoding:NSUTF8StringEncoding]];


    NSURLConnection *connect = [[NSURLConnection alloc]initWithRequest:theRequest delegate:self];

    if (connect) {
        webData = [[NSMutableData alloc]init];
    }
    else {
        NSLog(@"No Connection established");
    }

参见教程和示例代码

用于iOS的NTLM请求。我用过这个。

for NTLM request for iOS. I used this.

这篇关于如何在iOS中发送NTLM请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆