Skip to content
Open
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
32 changes: 14 additions & 18 deletions src/db/mormot.db.nosql.mongodb.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3766,6 +3766,15 @@ procedure TMongoClient.Auth(const DatabaseName, UserName, Digest: RawUtf8;
if err <> '' then
EMongoException.RaiseUtf8('%.OpenAuthSCRAM("%") step3: % - res=%',
[self, DatabaseName, err, res]);
//here server version requires auth before calling buildInfo
if VarIsEmptyOrNull(_Safe(fServerBuildInfo)^.Value['versionArray']) then begin
fConnections[0].RunCommand('admin', 'buildinfo', fServerBuildInfo);
with _Safe(fServerBuildInfo)^.A['versionArray']^ do
if count = 4 then
fServerBuildInfoNumber := // e.g. 02040900 for MongoDB 2.4.9
integer(Values[0]) * 1000000 + integer(Values[1]) * 10000 +
integer(Values[2]) * 100 + integer(Values[3]);
end;
end;
end;
end;
Expand All @@ -3779,6 +3788,9 @@ procedure TMongoClient.AfterOpen;
if VarIsEmptyOrNull(fServerBuildInfo) then
begin
fConnections[0].RunCommand('admin', 'buildinfo', fServerBuildInfo);
if _Safe(fServerBuildInfo)^.U['codeName'] = 'Unauthorized' then
fServerBuildInfoNumber := 8 * 1000000 + 1 * 10000 //from 8.1 up auth is required before calling buildInfo -> set min db-version
else
with _Safe(fServerBuildInfo)^.A['versionArray']^ do
if count = 4 then
fServerBuildInfoNumber := // e.g. 02040900 for MongoDB 2.4.9
Expand All @@ -3793,24 +3805,7 @@ procedure TMongoClient.AfterOpen;
c.AddItemText('zlib');
fConnections[0].RunCommand('admin',
BsonVariant(['hello', 1,
'client',
'{',
'application',
'{',
'name', Executable.ProgramName,
'}',
'driver',
'{',
'name', SYNOPSE_FRAMEWORK_NAME,
'version', SYNOPSE_FRAMEWORK_VERSION,
'}',
'os',
'{',
'type', OS_TEXT,
'name', OSVersionShort,
'architecture', CPU_ARCH_TEXT,
'}',
'}',
'saslSupportedMechs', 'admin.admin',
'compression', variant(c)
]), fServerInfo);
with _Safe(fServerInfo, dvObject)^ do
Expand Down Expand Up @@ -4751,3 +4746,4 @@ initialization

end.