| 382 | { } |
| 383 | |
| 384 | int WinSspiServer::authenticate(Firebird::CheckStatusWrapper* status, |
| 385 | IServerBlock* sBlock, |
| 386 | IWriter* writerInterface) |
| 387 | { |
| 388 | try |
| 389 | { |
| 390 | sspiData.clear(); |
| 391 | unsigned int length; |
| 392 | const unsigned char* bytes = sBlock->getData(&length); |
| 393 | sspiData.add(bytes, length); |
| 394 | |
| 395 | if (done && !length && !sspi.isActive()) |
| 396 | return AUTH_SUCCESS; |
| 397 | |
| 398 | if (!sspi.accept(sspiData)) |
| 399 | return AUTH_CONTINUE; |
| 400 | |
| 401 | if (!sspi.isActive()) |
| 402 | { |
| 403 | bool wheel = false; |
| 404 | string login; |
| 405 | AuthSspi::GroupsList grNames; |
| 406 | sspi.getLogin(login, wheel, grNames); |
| 407 | ISC_systemToUtf8(login); |
| 408 | |
| 409 | // publish user name obtained during SSPI handshake |
| 410 | writerInterface->add(status, login.c_str()); |
| 411 | if (status->getState() & IStatus::STATE_ERRORS) |
| 412 | return AUTH_FAILED; |
| 413 | |
| 414 | // is it suser account? |
| 415 | if (wheel) |
| 416 | { |
| 417 | writerInterface->add(status, FB_DOMAIN_ANY_RID_ADMINS); |
| 418 | if (status->getState() & IStatus::STATE_ERRORS) |
| 419 | return AUTH_FAILED; |
| 420 | |
| 421 | writerInterface->setType(status, FB_PREDEFINED_GROUP); |
| 422 | |
| 423 | if (status->getState() & IStatus::STATE_ERRORS) |
| 424 | return AUTH_FAILED; |
| 425 | } |
| 426 | |
| 427 | // walk groups to which login belongs and list them using writerInterface |
| 428 | Firebird::string grName; |
| 429 | |
| 430 | for (unsigned n = 0; n < grNames.getCount(); ++n) |
| 431 | { |
| 432 | grName = grNames[n]; |
| 433 | ISC_systemToUtf8(grName); |
| 434 | writerInterface->add(status, grName.c_str()); |
| 435 | |
| 436 | if (status->getState() & IStatus::STATE_ERRORS) |
| 437 | return AUTH_FAILED; |
| 438 | |
| 439 | writerInterface->setType(status, "Group"); |
| 440 | |
| 441 | if (status->getState() & IStatus::STATE_ERRORS) |
nothing calls this directly
no test coverage detected