Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
mkmf.log
scratch.rb
*.sw[op]
.idea
1 change: 1 addition & 0 deletions lib/autodiscover/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ module Autodiscover
class Error < ::StandardError; end

class ArgumentError < Error; end
class VersionError < Error; end
end
35 changes: 19 additions & 16 deletions lib/autodiscover/server_version_parser.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
module Autodiscover
class ServerVersionParser

VERSIONS = {
8 => {
0 => "Exchange2007",
1 => "Exchange2007_SP1",
2 => "Exchange2007_SP1",
3 => "Exchange2007_SP1",
0 => 'Exchange2007',
1 => 'Exchange2007_SP1',
2 => 'Exchange2007_SP1',
3 => 'Exchange2007_SP1'
},
14 => {
0 => "Exchange2010",
1 => "Exchange2010_SP1",
2 => "Exchange2010_SP2",
3 => "Exchange2010_SP2",
0 => 'Exchange2010',
1 => 'Exchange2010_SP1',
2 => 'Exchange2010_SP2',
3 => 'Exchange2010_SP2'
},
15 => {
0 => "Exchange2013",
1 => "Exchange2013_SP1",
0 => 'Exchange2013', # Minor builds starting from 847 are Exchange2013_SP1
1 => 'Exchange2016',
2 => 'Exchange2019',
20 => 'Exchange2016' # This is Office365
}
}
}.freeze

def initialize(hexversion)
@version = hexversion.hex.to_s(2).rjust(hexversion.size*4, '0')
@version = hexversion.hex.to_s(2).rjust(hexversion.size * 4, '0')
end

def major
Expand All @@ -37,9 +38,11 @@ def build
end

def exchange_version
v = VERSIONS[major][minor]
v.nil? ? VERIONS[8][0] : v
end
version = VERSIONS[major][minor]
raise Autodiscover::VersionError, "Unknown version string: #{@version}" unless version

version = 'Exchange2013_SP1' if version == 'Exchange2013' && build >= 847
version
end
end
end
2 changes: 1 addition & 1 deletion lib/autodiscover/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Autodiscover
VERSION = "1.0.2"
VERSION = '1.0.3'.freeze
end