Форум по Delphi программированию

Delphi Sources



Вернуться   Форум по Delphi программированию > Все о Delphi > Интернет и сети
Ник
Пароль
Регистрация <<         Правила форума         >> FAQ Пользователи Календарь Поиск Сообщения за сегодня Все разделы прочитаны

Ответ
 
Опции темы Поиск в этой теме Опции просмотра
  #1  
Старый 15.12.2008, 20:10
Аватар для M.A.D.M.A.N.
M.A.D.M.A.N. M.A.D.M.A.N. вне форума
Sir Richard Abramson
 
Регистрация: 05.04.2008
Сообщения: 5,505
Версия Delphi: XE10
Репутация: выкл
По умолчанию Аутентификация

Подскажите плз. как можно программо аутентифицироваться для открытия фала из сетевой папки с ограниченным доступом?
__________________
— Как тебя понимать?
— Понимать меня не обязательно. Обязательно меня любить и кормить вовремя.


На Delphi, увы, больше не программирую.
Рекомендуемая литература по программированию
Ответить с цитированием
  #2  
Старый 16.12.2008, 07:23
k@Z@k k@Z@k вне форума
Новичок
 
Регистрация: 31.07.2007
Сообщения: 55
Репутация: 12
По умолчанию

Я делал так:
1. Создавал сетевой диск/папку (проходил аунтефикацию, добовлял в систему)
2. работал с файлами.
3. дисконект
Код:
//-------------connect-------------------------
var
  lpNetResource: TNetResource;
  strMessage: string;
  nError: DWORD;
begin
  with lpNetResource do
    begin
      dwType := RESOURCETYPE_DISK;
      lpLocalName := 'Y:';
      lpRemoteName := '\\10.101.0.21\Новая1';
      lpProvider := '';
    end;
  nError := WNetAddConnection2(lpNetResource, 'password', 'login', 0);

  case nError of
    ERROR_ACCESS_DENIED: strMessage :=
      'Access to the network resource was denied.';
    ERROR_ALREADY_ASSIGNED: strMessage :=
      'The local device specified by lpLocalName is already connected to a network resource.';
    ERROR_BAD_DEV_TYPE: strMessage :=
      'The type of local device and the type of network resource do not match.';
    ERROR_BAD_DEVICE: strMessage :=
      'The value specified by lpLocalName is invalid.';
    ERROR_BAD_NET_NAME: strMessage :=
      'The value specified by lpRemoteName is not acceptable to any network resource provider. The resource name is invalid, or the named resource cannot be located.';
    ERROR_BAD_PROFILE: strMessage :=
      'The user profile is in an incorrect format.';
    ERROR_BAD_PROVIDER: strMessage :=
      'The value specified by lpProvider does not match any provider.';
    ERROR_BUSY: strMessage :=
      'The router or provider is busy, possibly initializing. The caller should retry.';
    ERROR_CANCELLED: strMessage :=
      'The attempt to make the connection was cancelled by the user through a dialog box from one of the network resource providers, or by a called resource.';
    ERROR_CANNOT_OPEN_PROFILE: strMessage :=
      'The system is unable to open the user profile to process persistent connections.';
    ERROR_DEVICE_ALREADY_REMEMBERED: strMessage :=
      'An entry for the device specified in lpLocalName is already in the user profile.';
    ERROR_EXTENDED_ERROR: strMessage :=
      'A network-specific error occured. Call the WNetGetLastError function to get a description of the error.';
    ERROR_INVALID_PASSWORD: strMessage := 'The specified password is invalid.';
    ERROR_NO_NET_OR_BAD_PATH: strMessage :=
      'A network component has not started, or the specified name could not be handled.';
    ERROR_NO_NETWORK: strMessage := 'There is no network present.';
    ERROR_LOGON_FAILURE: strMessage :=
      'Logon failure: unknown user name or bad password.';
    ERROR_BAD_NETPATH: strMessage := 'The network path was not found.';
    ERROR_SESSION_CREDENTIAL_CONFLICT: strMessage :=
      'The credentials supplied conflict with an existing set of credentials.';

    else
      strMessage := 'No Error';
  end;

  if nError <> NO_ERROR then
    strMessage := 'Error-' + IntToStr(nError) + #13 + strMessage
  else
    strMessage := 'Error-' + IntToStr(nError);

  ShowMessage(strMessage);
end;

//--------disconnect-----
 WNetCancelConnection('Y:', True);
Ответить с цитированием
Ответ


Delphi Sources

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать темы
Вы не можете отвечать на сообщения
Вы не можете прикреплять файлы
Вы не можете редактировать сообщения

BB-коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход


Часовой пояс GMT +3, время: 17:42.


 

Сайт

Форум

FAQ

RSS лента

Прочее

 

Copyright © Форум "Delphi Sources" by BrokenByte Software, 2004-2023

ВКонтакте   Facebook   Twitter