Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2008.04.20;
Скачать: CL | DM;

Вниз

Как узнать заблокирована учетная запись или нет   Найти похожие ветки 

 
suspeded   (2007-08-15 14:30) [0]

?


 
Lacmus ©   (2007-08-15 14:37) [1]

NetUserGetInfo ?


 
suspeded   (2007-08-15 14:44) [2]

Да, спасибо, я ее даже сам там нашел.
Но код

#ifndef UNICODE
#define UNICODE
#endif

#include <stdio.h>
#include <windows.h>
#include <lm.h>

int wmain(int argc, wchar_t *argv[])
{
  DWORD dwLevel = 10;
  LPUSER_INFO_10 pBuf = NULL;
  NET_API_STATUS nStatus;

  if (argc != 3)
  {
     fwprintf(stderr, L"Usage: %s \\\\ServerName UserName\n", argv[0]);
     exit(1);
  }
  //
  // Call the NetUserGetInfo function; specify level 10.
  //
  nStatus = NetUserGetInfo(argv[1],
                           argv[2],
                           dwLevel,
                           (LPBYTE *)&pBuf);
  //
  // If the call succeeds, print the user information.
  //
  if (nStatus == NERR_Success)
  {
   if (pBuf != NULL)
     {
        wprintf(L"\n\tAccount:      %s\n", pBuf->usri10_name);
        wprintf(L"\tComment:      %s\n", pBuf->usri10_comment);
        wprintf(L"\tUser comment: %s\n", pBuf->usri10_usr_comment);
        wprintf(L"\tFull name:    %s\n", pBuf->usri10_full_name);
     }
  }
  // Otherwise, print the system error.
  //
  else
     fprintf(stderr, "A system error has occurred: %d\n", nStatus);
  //
  // Free the allocated memory.
  //
  if (pBuf != NULL)
     NetApiBufferFree(pBuf);

  return 0;
}


не получается переработать. вот хотя бы что нужно подключить чтобы все объявленные типы принимались. типа NET_API_STATUS и т.п.


 
Lacmus ©   (2007-08-15 15:03) [3]



const
 UF_ACCOUNTDISABLE = $0002;

type
 NET_API_STATUS = DWORD;

 LPUSER_INFO_1 = ^USER_INFO_1;
 {$EXTERNALSYM LPUSER_INFO_1}
 PUSER_INFO_1 = ^USER_INFO_1;
 {$EXTERNALSYM PUSER_INFO_1}
 _USER_INFO_1 = record
   usri1_name: LPWSTR;
   usri1_password: LPWSTR;
   usri1_password_age: DWORD;
   usri1_priv: DWORD;
   usri1_home_dir: LPWSTR;
   usri1_comment: LPWSTR;
   usri1_flags: DWORD;
   usri1_script_path: LPWSTR;
 end;
 {$EXTERNALSYM _USER_INFO_1}
 USER_INFO_1 = _USER_INFO_1;
 {$EXTERNALSYM USER_INFO_1}
 TUserInfo1 = USER_INFO_1;
 PUserInfo1 = PUSER_INFO_1;

function NetUserGetInfo(servername, username: LPCWSTR; level: DWORD;
   var bufptr: PByte): NET_API_STATUS; stdcall; external "netapi32.dll";

function NetApiBufferFree(Buffer: Pointer): NET_API_STATUS; stdcall; external "netapi32.dll";

procedure TForm38.Button1Click(Sender: TObject);
var
 UserInfo1: PUserInfo1;
begin
 if NetUserGetInfo(nil, "Guest", 1, PByte(UserInfo1)) = 0 then try
   if (UserInfo1.usri1_flags and UF_ACCOUNTDISABLE) <> 0 then
     ShowMessage("Account disabled")
   else
     ShowMessage("Account enabled")
 finally
   NetApiBufferFree(UserInfo1)
 end else
   ShowMessage("Fail")
end;



 
suspeded   (2007-08-15 15:07) [4]

Ну ты крут... )



Страницы: 1 вся ветка

Текущий архив: 2008.04.20;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.019 c
15-1204721767
Petr V. Abramov
2008-03-05 15:56
2008.04.20
Позаботились об отечественном IT


2-1206777642
MSD
2008-03-29 11:00
2008.04.20
Вопрос по тексту в МЕМО


3-1196068794
Paradise
2007-11-26 12:19
2008.04.20
Перекрытие временных периодов


15-1204861461
Slider007
2008-03-07 06:44
2008.04.20
С днем рождения ! 7 марта 2008 пятница


15-1204887995
Igor_
2008-03-07 14:06
2008.04.20
define для определения версии C++ Builder