2013-04-25 1 views
0

UserGroup.GetUserInfo의 결과를 얻는 방법이 있습니까? 예를 들어 UserGroup.GetRolesAndPermissionsForCurrentUser과 같이 쿼리 할 사용자를 지정하지 않아도됩니까?현재 로그인 한 사용자에 대한 셰어 포인트 사용자 정보를 가져 옵니까? (SOAP API)

특히 사용자 ID를 얻으려고합니다 (문서가 현재 로그인 한 사용자에게 체크 아웃되었는지 여부를 알 수 있도록). 안타깝게도 스마트 카드를 사용하여 자격 증명을 제공합니다. 실제 문서 라이브러리에 입력 한 사용자 이름이나 비밀번호가 없습니다. 따라서 도메인이 아닌 GetUserInfo의 사용자 이름을 사용할 수 없습니다. 스마트 카드를 사용하지 않는 방법입니다. .

또한, 나는 iOS에서, 그래서 난 정말 좋은 셰어 API를 사용할 필요가 없습니다 - 모든 것이 2007/2010 SOAP WebService를 API를 통해 사용할 수

감사해야합니다!

답변

1

UserGroup.GetCurrentUserInfo을 사용할 수 있습니다. Sharepoint SOAP 문서는 여기 http://msdn.microsoft.com/en-us/library/websvcusergroup.usergroup.getcurrentuserinfo(v=office.14).aspx에서 찾을 수 있습니다.

Sharepoint 인스턴스에 액세스 할 수있는 경우 SOAP 봉투 및 응답을 여기에서 확인할 수 있습니다. htttp : //your.sharepointserver.com/_vti_bin/usergroup.asmx? op = GetCurrentUserInfo (이 URL을 앱의 실제 요청).

다음은 AFNetworking 및 하위 클래스 AFHTTPClient를 기반으로 한 구현 예입니다.

// Get user info for currently signed in user 
- (void)currentUserInfoWithSuccessBlock:(void(^)(SharepointCurrentUserResponse *response))successBlock 
           failBlock:(void(^)(NSError *error))failBlock { 

    NSMutableURLRequest *request = [self requestWithMethod:@"POST" 
                path:@"_vti_bin/UserGroup.asmx" 
               parameters:nil]; 

    NSString *soapEnvelope = 
    @"<?xml version=\"1.0\" encoding=\"utf-8\"?>" 
    @"<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/\">" 
    @"<soap:Body>" 
    @"<GetCurrentUserInfo xmlns=\"http://schemas.microsoft.com/sharepoint/soap/directory/\" />" 
    @"</soap:Body>" 
    @"</soap:Envelope>"; 

    // Set headers 
    [request setValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; 
    [request setValue:@"http://schemas.microsoft.com/sharepoint/soap/directory/GetCurrentUserInfo" forHTTPHeaderField:@"SOAPAction"]; 

    // Content length 
    NSString *contentLength = [NSString stringWithFormat:@"%d", soapEnvelope.length]; 
    [request setValue:contentLength forHTTPHeaderField:@"Content-Length"]; 

    // Set body 
    [request setHTTPBody:[soapEnvelope dataUsingEncoding:NSUTF8StringEncoding]]; 

    AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request 
    success:^(AFHTTPRequestOperation *operation, id responseData) { 
     NSString *xmlString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; 
     NSLog(@"XML response : %@", xmlString); 

     // Parse the response 
     SharepointCurrentUserResponse *response = ... 

     successBlock(reponse); 
    } 
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) { 
     NSLog(@"Get user info failed with reason: %@ status code %d", 
      error, operation.response.statusCode); 

     failBlock(error); 
    }]; 

    // Que operation 
    [self enqueueHTTPRequestOperation:operation]; 
} 
+0

2010 년이 아닌 2007 년에만 사용할 수 있습니다. 나를 위해 작동하지 않지만 귀하의 답변은 2010+ – cscott530

관련 문제