Avatar of vtokmak
vtokmak
 asked on

Delphi Active Direcrtory integration (LDAP)

I wanna active directory integration with delphi. i wrote a class for this. it uses (LDAPLib = 'wldap32.dll'). I succesfully connect , search etc. But could not add / delete user, I think i have to use, ldap_add_s command for add. can someone helps me about add and delete LDAP object from delphi. ( dont link, pure code pleae :) )
DatabasesEditors IDEsDelphi

Avatar of undefined
Last Comment
Geert G

8/22/2022 - Mon
Geert G

do you have sufficient priviges for this with your account ?
you can check it with www.sysinternals.com -> ADExplorer

vtokmak

ASKER
i dont need executables. Many tool gives these informations. My problem is specific. How can i add / delete user with LDapLib ?
Geert G

have you got the code
AND do you have sufficient priviges for this with your account ?

i was suggesting a way to check the priviliges ...

you may have the code, but if you don't have the priviliges to change in AD, the tests will fails
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
vtokmak

ASKER
what d u taking about account priviliges. i pay here money. i asked a question and waiting answer. wtf
vtokmak

ASKER
lol miss :)
Geert G

this is the code to create the user
don't have it in Delphi

http://msdn.microsoft.com/en-us/library/ms676723(VS.85).aspx
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
RemkoEB

vtokmak

ASKER
ADSI is good. i implemented this on my source. Search, listing are good. but i need add and delete user.
ASKER CERTIFIED SOLUTION
RemkoEB

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
vtokmak

ASKER
thanks hun.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Geert G

i guess the try except was screen filling ?
RemkoEB

I justed wanted to emphasize that adsi exceptions need to be handled (and it was easier copy/pasting from my existing code ;-)
Geert G

so you are a fan of a lot of code ?

and why not like this ?
  procedure SetAttrib(Obj: IADsUser; AttribName, AttribValue: string);
  begin
    try
      obj.Put(AttribName, AtrtibValue);
    except
      // do nothing
    end;
  end; 
 
var
  sPathName: WideString;
  aOU: IADsContainer;
  aUser: IADsUser;
 
sPathName := 'CN=Users,DC=domain,DC=org';
  try
    ADsGetObject(sPathName, IADsContainer, aOU);
  except
    on E : Exception do begin
       // always wrap ADSI actions in try..except blocks
    end;
  end;
 
  try
    aUser := aOU.Create('user', sCN) as IADsUser;
  except
    // skip
  end;
  if Assigned(aUser) then 
  try
    SetAttrib(aUser, 'sAMAccountName', edtUsername.Text);
    SetAttrib(aUser, 'givenName', edtVoorNaam.Text);
    SetAttrib(aUser, 'sn', edtAchterNaam.Text);
    SetAttrib(aUser, 'displayName', edtVolledigeNaam.Text);
    SetAttrib(aUser, 'displayNamePrintable', edtSimpleDisplayName.Text);
    SetAttrib(aUser, 'userPrincipalName', edtGebruikersNaam.Text);
    SetAttrib(aUser, 'sAMAccountName', edtUsername.Text);
    aUser.SetInfo;
  except
    // skip 
  end;

Open in new window

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.