Reputation: 1957
Domain 2008 R2, DC. Administrator. DelphiXe2.
I Get User's info with ADOConnection1.SQL:
select extensionAttribute1, extensionAttribute2, cn, sn, givenname, displayName, sAMAccountName, userPrincipalName, mail, title, telephonenumber, company, department, description, objectSid, physicalDeliveryOfficeName, userAccountControl from 'LDAP://dc=ru/dc=mydomain/OU=User' where objectCategory = 'person' and objectClass='user' and userAccountControl<>514 and userAccountControl<>546 order by name
All work normal. I put new user:
Uses ActiveDs_TLB, ActiveX, ComObj;
..
var Usr: IADsUser; Comp: IADsContainer;
begin
try
CoInitialize(nil);
Comp:=GetObject('WinNT://localhost') as IADsContainer;
Usr:=comp.Create('user','Koko') as IADsUser;
usr.SetPassword('Fa123456789');
// usr.FirstName:='Pups';
Usr.SetInfo;
except ..
end;
end;
Questions:
Or how correctly to add the user with all attributes in active directory?
Upvotes: 1
Views: 365
Reputation: 7340
After creating the user first call SetInfo before setting the password.
Upvotes: 1