2011-07-27 1 views
1

SharePoint 2010 목록과 통합 된 MS Access 2007 응용 프로그램을 데이터 원본으로 만듭니다.MS Access/VBA를 사용하여 Sharepoint 그룹 내의 사용자 목록을 얻는 방법

특정 셰어 포인트 사용자 그룹의 구성원 인 사용자를 검사하여 응용 프로그램에 구축 할 일부 기능을 지원해야합니다. VBA 코드 내에서 그룹에 대한 셰어 포인트 사용자의 관계를 확인하는 방법이 있습니까? 감사.

답변

1

나는 다음 몇 가지 미세 조정이 필요할 수 있습니다 XML 파서

에 응답을 공급하지만,이 거기 당신에게 대부분의 방법을 얻을 것이다, SOAP를 통해 CAML 쿼리를 사용합니다. 비슷한 것을 사용합니다.

복잡한 것처럼 보일 수도 있지만 모두 잘하면 커뮤니티의 URL을 변경해야합니다.

'Debug.Print .responseText 및'debug.print .status를 사용하여 문제를 디버깅 할 수 있습니다. 200이라는 상태는 사이트가 ok임을 나타냅니다.

function start_here() 

set user_list = get_users("http://sites.company.com/sites/00672") 

for each n in user_list 
    debug.print str(n), userlist(str(n)) 
next 

end function 

Function get_users(site_URL) 

Dim xmlDoc 
Set xmlDoc = CreateObject("Msxml2.DOMDocument") 

request = "<?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>" + _ 
       "<GetUserCollectionFromSite xmlns='http://schemas.microsoft.com/sharepoint/soap/directory/' />" + _ 
      "</soap:Body>" + _ 
     "</soap:Envelope>" 

    With CreateObject("Microsoft.XMLHTTP") 
     .Open "Get", site_URL & "/_vti_bin/usergroup.asmx", False, Null, Null 
     .setRequestHeader "Content-Type", "text/xml; charset=utf-8" 
     .setRequestHeader "SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/directory/GetUserCollectionFromSite" 
     .send request 
     'Debug.Print .status 
     'Debug.Print .responseText 
     xmlDoc.LoadXML (.responseText) 
    End With 

Set nodesCollection = xmlDoc.SelectNodes("//Users/User") 
Set ID = xmlDoc.createNode(1, "xml", "") 
Set user_name = xmlDoc.createNode(1, "xml", "") 

Set user_col = New Collection 

    For Each nodeElement In nodesCollection 
     Set ID = nodeElement.Attributes.getNamedItem("ID") 
     Set user_name = nodeElement.Attributes.getNamedItem("Name") 
     user_col.Add user_name.Text), Str(ID.Text) 
    Next 

Set get_users = user_col 

end function 
관련 문제