Class: Viewpoint::SPWS::Websvc::UserGroup

Inherits:
Object
  • Object
show all
Includes:
WebServiceBase
Defined in:
lib/viewpoint/spws/websvc/user_group.rb

Overview

This class represents the Sharepoint User and Groups Web Service.

Constant Summary

Constants included from WebServiceBase

WebServiceBase::NAMESPACES

Constants included from Viewpoint::SPWS

VERSION

Instance Attribute Summary

Attributes included from WebServiceBase

#spcon

Attributes included from Viewpoint::SPWS

#logger

Instance Method Summary collapse

Methods included from Viewpoint::SPWS

root_logger, set_log_level

Constructor Details

#initialize(spcon) ⇒ UserGroup

Returns a new instance of UserGroup.



24
25
26
27
28
# File 'lib/viewpoint/spws/websvc/user_group.rb', line 24

def initialize(spcon)
  @default_ns = 'http://schemas.microsoft.com/sharepoint/soap/directory/'
  @ws_endpoint = '_vti_bin/UserGroup.asmx'
  super
end

Instance Method Details

#get_all_user_collection_from_webObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/viewpoint/spws/websvc/user_group.rb', line 30

def get_all_user_collection_from_web
  soapmsg = build_soap_envelope do |type, builder|
    if(type == :header)
    else
      builder.GetAllUserCollectionFromWeb {
        builder.parent.default_namespace = @default_ns
      }
    end
  end
  soaprsp = Nokogiri::XML(send_soap_request(soapmsg.doc.to_xml))
  ns = {'xmlns' => @default_ns}
  users = []
  soaprsp.xpath('//xmlns:Users/xmlns:User', ns).each do |li|
    users << Types::User.new(self,li)
  end
  users
end

#get_user_info(user) ⇒ Object

Returns information about a specified user

Parameters:

  • user (String)

    A username to retrieve infor for. It must be of the form DOMAINusername



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/viewpoint/spws/websvc/user_group.rb', line 51

def (user)
  soapmsg = build_soap_envelope do |type, builder|
    if(type == :header)
    else
      builder.GetUserInfo {
        builder.parent.default_namespace = @default_ns
        builder.userLoginName(user)
      }
    end
  end
  soaprsp = Nokogiri::XML(send_soap_request(soapmsg.doc.to_xml))
  ns = {'xmlns' => @default_ns}
  user = soaprsp.xpath('//xmlns:GetUserInfo/xmlns:User', ns).first
  Types::User.new(self,user)
end

#get_user_login_from_email(emails) ⇒ Hash

Get user logins from e-mail addresses

Parameters:

  • emails (Array<String>)

    an Array of e-mail addresses to search for

Returns:

  • (Hash)

    a hash of email to login mappings

See Also:



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/viewpoint/spws/websvc/user_group.rb', line 71

def (emails)
  soapmsg = build_soap_envelope do |type, builder|
    if(type == :header)
    else
      builder.GetUserLoginFromEmail {
        builder.parent.default_namespace = @default_ns
        builder.emailXml {
          builder.Users {
            emails.each do |email|
              builder.User(:Email => email)
            end
          }
        }
      }
    end
  end
  soaprsp = Nokogiri::XML(send_soap_request(soapmsg.doc.to_xml))
  ns = {'xmlns' => @default_ns}
  logins = {}
  soaprsp.xpath('//xmlns:GetUserLoginFromEmail/xmlns:User', ns).each do |li|
    logins[li['Email']] = li['Login']
  end
  logins
end