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

Вниз

Не могу переместить пользователя из одной группы в другую.   Найти похожие ветки 

 
Denin ©   (2006-01-31 17:42) [0]

Не могу переместить пользователя из одной группы в другую.
Master - контроллер домена DMAIN, группа в домене есть. Выдает ошибку 2220
(когда пробую варианты то ошибки 2221,2223).
Пробовал менять "dmain\Guests" на "Guests", "Test" на "dmain\Test" всеравно не помогает.

код вот такой:

type
LPBYTE = Windows.PBYTE;
NET_API_STATUS = DWORD;
_GROUP_USERS_INFO_0 = record
  grui0_name: LPWSTR;
end;
const
NetApi32 = "netapi32.dll";

implementation

{$R *.dfm}

function NetUserSetGroups(servername, username: LPCWSTR; level: DWORD; buf: LPBYTE; num_entries: DWORD): NET_API_STATUS; stdcall; external netapi32 name "NetUserSetGroups"

procedure TForm1.Button1Click(Sender: TObject);
var
gi      : _GROUP_USERS_INFO_0;
gn,un,srv   : WideString;
nStatus : NET_API_STATUS;
begin
un:="Test";
srv := "\\master";
gi.grui0_name:="dmain\Guests";
nStatus:=NetUserSetGroups(PWideChar(srv),PWideChar(un),0,@gi,1);
WriteLn(nStatus);
ReadLn;
end;


 
Rouse_ ©   (2006-01-31 17:58) [1]

NERR_GroupNotFound = 2220 The group name could not be found.
NERR_UserNotFound = 2221 The user name could not be found.  
NERR_ResourceNotFound = 2222 The resource name could not be found.  

User account names are limited to 20 characters and group names are limited to 256 characters. In addition, account names cannot be terminated by a period and they cannot include commas or any of the following printable characters: ", /, \, [, ], :, |, <, >, +, =, ;, ?, *. Names also cannot include characters in the range 1-31, which are nonprintable.


 
Denin ©   (2006-02-01 09:35) [2]

Спасибо за расшифровку... что делать дальше? Не работает ведь...
вроде все есть... как ему правильно задать эти имена?


 
BiN ©   (2006-02-01 10:03) [3]


> srv := "\\master";


Убирать слэши пробовал?


 
Чапаев ©   (2006-02-01 10:18) [4]


> "dmain\Guests"

Это из области антинаучной фантастики, имхо. Есть такая стандартная группа "Domain Guests", а "domain_name\guests" -- лажа...


 
Denin ©   (2006-02-01 12:35) [5]

натренировался со слешами... получил вот такое:

un:="TestDenis";
srv := "\\master";
gi.grui0_name:="ASU";
nStatus:=NetUserSetGroups(PWideChar(srv),PWideChar(un),0,@gi,1);

теперь ошибка 2234...


 
Denin ©   (2006-02-01 12:41) [6]

Добился вот такого:
ошибка 2234 "This operation is not allowed on this special group".

un:="Test";
srv := "\\master";
gi.grui0_name:="Guests";
nStatus:=NetUserSetGroups(PWideChar(srv),PWideChar(un),0,@gi,1);


 
Denin ©   (2006-02-01 13:45) [7]

ВСЕМ ОГРОМНОЕ СПАСИБО ЗА ПОМОЩЬ!!!!
Ларчик просто открывался. Надо было ему список групп подсовывать.
Среди которых обязательно Primary Group + те группы в которые нужно
добавить пользователя.

Примерный код вот такой (где Domain Users - Primary Group для пользователя Test):

type
LPBYTE = Windows.PBYTE;
NET_API_STATUS = DWORD;
_GROUP_USERS_INFO_0 = record
 grui0_name: LPWSTR;
end;
const
NetApi32 = "netapi32.dll";

implementation

{$R *.dfm}

function NetUserSetGroups(servername, username: LPCWSTR; level: DWORD; buf: LPBYTE; num_entries: DWORD): NET_API_STATUS; stdcall; external netapi32 name "NetUserSetGroups"

procedure TForm1.Button1Click(Sender: TObject);
var
gi      : array[0..1] of _GROUP_USERS_INFO_0;
gn,un,srv   : WideString;
nStatus : NET_API_STATUS;
begin
un:="TestDenis";
srv := "\\master";
gi[0].grui0_name:="Domain Users";
gi[1].grui0_name:="ASU";
nStatus:=NetUserSetGroups(PWideChar(srv),PWideChar(un),0,@gi,2);
WriteLn(nStatus);
ReadLn;
end;



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

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

Наверх




Память: 0.48 MB
Время: 0.052 c
2-1143641950
001
2006-03-29 18:19
2006.04.16
Oracle server, client


2-1143555916
Juice
2006-03-28 18:25
2006.04.16
Отличие между drag&amp;drop и drag&amp;dock


2-1143713097
Yegorchic
2006-03-30 14:04
2006.04.16
CheckBox.Caption в 2 строки


15-1143021838
Nsk3D
2006-03-22 13:03
2006.04.16
Шрифты.создание.модификация.


2-1144205240
Sw
2006-04-05 06:47
2006.04.16
Стиль столбца DBGrid