Registriert seit: 29. Mai 2002
37.621 Beiträge
Delphi 2006 Professional
|
29. Jan 2003, 05:16
Irgendwie glaube ich, dass ich mich im Kreise drehe. Ich bin, glaube ich, wieder bei der Ursprungsversion angekommen:
Delphi-Quellcode:
procedure AddUserProc(sComputer: String);
var
ui3 : Pointer; // USER_INFO_3; //
szBuffer : array[0..255] of Char;
s, sUser : String;
dwNetError : NET_API_STATUS;
begin
Sender := VOID;
GetMem(ui3, sizeof(USER_INFO_3));
try
GetDlgItemText(hApp, IDC_EDTNAME, szBuffer, sizeof(szBuffer));
sUser := s;
s := String(szBuffer);
PUSERINFO3(ui3)^.usri3_name := PWideChar(WideString(s));
GetDlgItemText(hApp, IDC_EDTDESCRIPTION, szBuffer, sizeof(szBuffer));
s := String(szBuffer);
PUSERINFO3(ui3)^.usri3_comment := PWideChar(WideString(s));
GetDlgItemText(hApp, IDC_EDTFULLNAME, szBuffer, sizeof(szBuffer));
s := String(szBuffer);
PUSERINFO3(ui3)^.usri3_full_name := PWideChar(WideString(s));
GetDlgItemText(hApp, IDC_EDTHOMEDIR, szBuffer, sizeof(szBuffer));
s := String(szBuffer);
PUSERINFO3(ui3)^.usri3_home_dir := PWideChar(WideString(s));
PUSERINFO3(ui3)^.usri3_flags := 0;
if IsDlgButtonChecked(hApp, IDC_CHKCANTCHNGPW) = BST_CHECKED then
PUSERINFO3(ui3)^.usri3_flags := PUSERINFO3(ui3)^.usri3_flags or UF_PASSWD_CANT_CHANGE
else
PUSERINFO3(ui3)^.usri3_flags := PUSERINFO3(ui3)^.usri3_flags and not UF_PASSWD_CANT_CHANGE;
if IsDlgButtonChecked(hApp, IDC_CHKDISABLED) = BST_CHECKED then
PUSERINFO3(ui3)^.usri3_flags := PUSERINFO3(ui3)^.usri3_flags or UF_ACCOUNTDISABLE
else
PUSERINFO3(ui3)^.usri3_flags := PUSERINFO3(ui3)^.usri3_flags and not UF_ACCOUNTDISABLE;
if IsDlgButtonChecked(hApp, IDC_CHKDONTEXPIRE) = BST_CHECKED then
PUSERINFO3(ui3)^.usri3_flags := PUSERINFO3(ui3)^.usri3_flags or UF_DONT_EXPIRE_PASSWD
else
PUSERINFO3(ui3)^.usri3_flags := PUSERINFO3(ui3)^.usri3_flags and not UF_DONT_EXPIRE_PASSWD;
if IsDlgButtonChecked(hApp, IDC_CHKLOCKED) = BST_CHECKED then
PUSERINFO3(ui3)^.usri3_flags := PUSERINFO3(ui3)^.usri3_flags or UF_LOCKOUT
else
PUSERINFO3(ui3)^.usri3_flags := PUSERINFO3(ui3)^.usri3_flags and not UF_LOCKOUT;
if IsDlgButtonChecked(hApp, IDC_CHKMUSTCHNGPW) = BST_CHECKED then
PUSERINFO3(ui3)^.usri3_password_expired := 1
else
PUSERINFO3(ui3)^.usri3_password_expired := 0;
dwNetError := NetUserAdd(nil, 3, ui3, nil); // hier steigt er mit dem RuntimeError 216 aus
finally
FreeMem(ui3, sizeof(USER_INFO_3));
end;
if IsDlgButtonChecked(hApp, IDC_CHKISADMIN) = BST_CHECKED then
dwNetError := AddToGroup('Administratoren', sUser, sComputer);
if IsDlgButtonChecked(hApp, IDC_CHKISPOWERUSER) = BST_CHECKED then
dwNetError := AddToGroup('Hauptbenutzer', sUser, sComputer);
if IsDlgButtonChecked(hApp, IDC_CHKISUSER) = BST_CHECKED then
dwNetError := AddToGroup('Benutzer', sUser, sComputer);
if IsDlgButtonChecked(hApp, IDC_CHKISGUEST) = BST_CHECKED then
dwNetError := AddToGroup('Gäste', sUser, sComputer);
if IsDlgButtonChecked(hApp, IDC_CHKISBACKUPOP) = BST_CHECKED then
dwNetError := AddToGroup('Sicherungs-Operatoren', sUser, sComputer);
if IsDlgButtonChecked(hApp, IDC_CHKISREPOP) = BST_CHECKED then
dwNetError := AddToGroup('Replikations-Operator', sUser, sComputer);
if dwNetError <> NERR_Success then
DisplayNetError(dwNetError);
end;
Mit dem Erfolg, dass der RuntimeError immer noch nicht weg ist.
Irgendwelche Vorschläge, Ideen?
Michael Ein Teil meines Codes würde euch verunsichern.
|