Contents LDAP Interface Previous Next

Adding a Directory Entry to an LDAP Server

The following example uses the LDAP CALL Routine Interface to add an entry to an LDAP directory.

data _null_;

  rc =0;  handle=0;
  server="alpair.unx.sas.com";
  port=8010;
  base="sasComponent=sasPublishSubscriber,cn=SAS,o=Alpine Airlines,c=US";
  bindDN=""; Pw="";

  /* open connection to LDAP server */
  call ldaps_open(handle, server, port, base, bindDn, Pw, rc);
  if rc ne 0 then do;
     msg = sysmsg();
     put msg;
  end;
  else
     put "LDAPS_OPEN call successful.";

  /* add the following entry, which has 6 attributes */
  entryName="saschannelcn=DeleteTest,cn=saschannels,sasComponent=sasPublishSubscribe,cn=SAS,o=SAS Institute,c=US";
  a1="objectclass";
  a1Value="saschannel";
  a2="sasSubject";
  a2Value="Steph's channel to test";
  a3="description";
  a3Value="Entry include/exclude testing";
  a4="sasFrequency";
  a4Value="bi-monthly";
  a5="SASDeliveryTransport";
  a5Value="queue";
  a5Value2="email";
  a5Value3="ftp";
  a6="sasSubscriberCn";
  a6Value="stephEmail";

  /* add entry (including all attributes and attribute values) */
  call ldaps_add(handle, entryName, rc, a1, 1, a1Value,
                                        a2, 1, a2Value,
                                        a3, 1, a3Value,
                                        a4, 1, a4Value,
                                        a5, 3, a5Value, a5Value2, a5Value3,
                                        a6, 1, a6Value);
  if rc ne 0 then do;
     msg = sysmsg();
     put msg;
  end;
  else
     put "LDAPS_ADD call successful.";

  /* close connection to LDAP server */
  call ldaps_close(handle,rc);
  if rc ne 0 then do;
     msg = sysmsg();
     put msg;
  end;
  else
     put "LDAPS_CLOSE call successful.";
  run;
quit;

Contents LDAP Interface Previous Next