@@ -7,6 +7,7 @@ import type { Document } from '../../bson';
77type MechanismProperties = {
88 gssapiCanonicalizeHostName ?: boolean ;
99 SERVICE_NAME ?: string ;
10+ SERVICE_REALM ?: string ;
1011} ;
1112
1213import * as dns from 'dns' ;
@@ -89,14 +90,20 @@ function makeKerberosClient(authContext: AuthContext, callback: Callback<Kerbero
8990 Object . assign ( initOptions , { user : username , password : password } ) ;
9091 }
9192
92- Kerberos . initializeClient (
93- `${ serviceName } ${ process . platform === 'win32' ? '/' : '@' } ${ host } ` ,
94- initOptions ,
95- ( err : string , client : KerberosClient ) : void => {
96- if ( err ) return callback ( new MongoDriverError ( err ) ) ;
97- callback ( undefined , client ) ;
93+ let spn : string ;
94+ if ( process . platform === 'win32' ) {
95+ spn = `${ serviceName } /${ host } ` ;
96+ if ( 'SERVICE_REALM' in mechanismProperties ) {
97+ spn = `${ spn } @${ mechanismProperties . SERVICE_REALM } ` ;
9898 }
99- ) ;
99+ } else {
100+ spn = `${ serviceName } @${ host } ` ;
101+ }
102+
103+ Kerberos . initializeClient ( spn , initOptions , ( err : string , client : KerberosClient ) : void => {
104+ if ( err ) return callback ( new MongoDriverError ( err ) ) ;
105+ callback ( undefined , client ) ;
106+ } ) ;
100107 }
101108 ) ;
102109}
0 commit comments