2007 Nov 02 6:50 AM
Hi,
does somebody built up a connection between SAP and LDAP? Would be neice ti exchange expreince on querying the emailadress from LDAP with ABAP or any other SAP tools (ALE, RFC whatever).
2007 Nov 02 7:37 AM
Hi here is the sample we recently used for getting e-mails ID from LDAP distribution lists...
FUNCTION Y_ISA_LDAP_UPDATE.
*"----
""Local interface:
*" IMPORTING
*" VALUE(EMAIL) TYPE AD_SMTPADR
*" TABLES
*" ATTRIBUTES_IN STRUCTURE LDAP_ATII
*" VALUES_IN STRUCTURE LDAP_VALI
*" ET_MESSAGES STRUCTURE CRMT_ISALES_RETURN
*"----
Modification Log
0001 08/02/2004 MFoley Created to update LDAP variables passed in
through attributes_in and values_in
structure based on email id.
*"----
data: dns_out like ldap_dnii occurs 0 WITH HEADER LINE,
SERVERID LIKE LDAPSERVER-SERVERID,
ws_tvarv like tvarv,
ws_attribute_lines(4) type n,
ws_attrs_io_lines(4) type n,
ws_attribute_index(4) type n,
ATTRS_IO like ldap_atii occurs 0 WITH HEADER LINE,
VALUES_IO like ldap_vali occurs 0 WITH HEADER LINE,
ws_attributes_delete like ldap_atii occurs 0 with header line,
search_term type c length 255,
SEARCH_TERM_2 TYPE C LENGTH 255,
FIELD_EXISTS TYPE C LENGTH 1.
data: w_test type n.
w_test = 1.
while w_test = 1.
endwhile.
*system bind----
SELECT SINGLE * FROM TVARV into corresponding fields of ws_tvarv
WHERE NAME = 'Y_ISA_F_ADAM_SERVER'.
SERVERID = WS_TVARV-LOW.
CALL FUNCTION 'LDAP_SYSTEMBIND'
EXPORTING
SERVERID = SERVERID
WRITEREAD = 'W'
WAIT_TIME = 5
EXCEPTIONS
NO_AUTHORIZ = 1
CONFIG_ERROR = 2
NOMORE_CONNS = 3
LDAP_FAILURE = 4
NOT_ALIVE = 5
OTHER_ERROR = 6
OTHERS = 7.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*search for record----
concatenate '(&(objectclass=)(cn=' email '))' into search_term.
clear: dns_out, attrs_io, values_io.
refresh: dns_out, attrs_io, values_io.
CALL FUNCTION 'LDAP_SEARCH'
EXPORTING
BASE = 'ou=Members,o=ADI Internet' "0001
BASE = 'OU=WebAdam,DC=Analog,DC=com' "0001
SCOPE = 2
MODE = 'C'
CROP = 'X'
CROP_DN_ATTR = 'X'
FILTER = SEARCH_TERM
TABLES
DNS_OUT = dns_out
ATTRS_IO = attrs_io
EXCEPTIONS
NO_AUTHORIZ = 1
CONN_OUTDATE = 2
LDAP_FAILURE = 3
NOT_ALIVE = 4
OTHER_ERROR = 5
OTHERS = 6.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
describe table attrs_io lines ws_attrs_io_lines.
if ws_attrs_io_lines = 0.
ET_MESSAGES-NUMBER = '998'.
ET_MESSAGES-ID = 'E'.
ET_MESSAGES-MESSAGE = 'User does not exist in Active Directory'.
ET_MESSAGES-LOG_NO = 'FE'.
APPEND ET_MESSAGES.
*unbind----
CALL FUNCTION 'LDAP_UNBIND'
EXCEPTIONS
CONN_OUTDATE = 1
LDAP_FAILURE = 2
NOT_ALIVE = 3
OTHER_ERROR = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
EXIT.
endif.
loop at attributes_in.
ws_attribute_index = sy-tabix.
read table values_in index ws_attribute_index.
check to see if field already is on Active Directory
field_exists = 'N'.
loop at attrs_io where text = attributes_in-text.
field_exists = 'Y'.
endloop.
if attribute is on active directory update it
if field_exists = 'Y'.
"If value exists, then update it - otherwise, delete
if values_in-text <> ''.
attributes_in-num1 = 2.
attributes_in-num2 = 1.
modify attributes_in.
else.
ws_attributes_delete-text = attributes_in-text.
append ws_attributes_delete.
delete attributes_in.
delete values_in index ws_attribute_index.
endif.
else.
If attribute isn't on active directory create it
if values_in-text <> ''.
" if values exists, then create it - otherwise remove
attributes_in-num1 = 0.
attributes_in-num2 = 1.
modify attributes_in.
else.
delete attributes_in.
delete values_in index ws_attribute_index.
endif.
endif.
endloop.
*CONCATENATE 'CN=' ALIAS ',OU=MEMBERS,O=ADI INTERNET' INTO SEARCH_TERM_2
LOOP AT DNS_OUT.
SEARCH_TERM_2 = DNS_OUT-TEXT.
ENDLOOP.
only execute modify if there's anything to be updated
describe table attributes_in lines ws_attribute_lines.
if ws_attribute_lines > 0.
CALL FUNCTION 'LDAP_MODIFY'
EXPORTING
DN = SEARCH_TERM_2
MODE = 'C'
TABLES
ATTRS_IN = attributes_in
VALUES_IN = values_in
EXCEPTIONS
NO_AUTHORIZ = 1
CONN_OUTDATE = 2
PARAM_ERROR = 3
LDAP_FAILURE = 4
HEXVAL_ERROR = 5
NOT_ALIVE = 6
OTHER_ERROR = 7
OTHERS = 8.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endif.
If any attributes need to be deleted, loop through
them one by one to remove (getting syntax errors when
I try to delete them all at one time).
loop at ws_attributes_delete.
clear: attrs_io, values_io.
refresh: attrs_io, values_io.
attrs_io-text = ws_attributes_delete-text.
attrs_io-num1 = 1.
attrs_io-num2 = 1.
append attrs_io.
CALL FUNCTION 'LDAP_MODIFY'
EXPORTING
DN = SEARCH_TERM_2
MODE = 'C'
TABLES
ATTRS_IN = attrs_io
VALUES_IN = values_io
EXCEPTIONS
NO_AUTHORIZ = 1
CONN_OUTDATE = 2
PARAM_ERROR = 3
LDAP_FAILURE = 4
HEXVAL_ERROR = 5
NOT_ALIVE = 6
OTHER_ERROR = 7
OTHERS = 8.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endloop.
*unbind----
CALL FUNCTION 'LDAP_UNBIND'
EXCEPTIONS
CONN_OUTDATE = 1
LDAP_FAILURE = 2
NOT_ALIVE = 3
OTHER_ERROR = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFUNCTION.
2007 Nov 02 6:54 AM
You can download novell e directory server (LDAP) from the following link
www.novell.com/products/edirectory/sap
for more information please go throught this link
http://help.sap.com/saphelp_nw04/helpdata/en/06/371640b7b6dd5fe10000000a155106/frameset.htm
and navigate to identity management->UME->UME Configuration->UME Data Source
Refer this link
http://help.sap.com/saphelp_nw04/helpdata/en/cc/cdd93f130f9115e10000000a155106/frameset.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/4e/4d0d40c04af72ee10000000a1550b0/frameset.htm
And some good SAP notes to have a look at are:
673824 - LDAP Issues for UME.
736471 - UME Configuration of multiple LDAP data sources.
Pls cjheck this:
http://help.sap.com/saphelp_nw04s/helpdata/en/48/d1d13f7fb44c21e10000000a1550b0/content.htm
How to configure LDAP in portal
The user management component of the Enterprise Portal leverages your existing landscape by using a corporate LDAP directory server as its central user data repository. It accesses any existing data schema by allowing you to map the attributes used in the schema.
In this step, you will connect to your LDAP server as an alternate user data source.
Log on to the Portal as Administrator
1.Navigate to System Administration ® System Configuration ®UMEConfiguration.
2.Choose the Modify Configuration button.
3.In Data Source, use the drop list to select the LDAP system of your landscape.
4.Choose the LDAP Server tab.
5.Enter the following values in the fields as follows
Server Name :Host Name of the Directory Server for example Idap.sap.corp
Port:Port of the LDAP directory server. for example 389
User:Distinguished name (DN) of user that is used to connect (bind) to the LDAP directory server.
cn=Directory Manager
For example: [email protected]
Password: Password of the user
User Path (Only required if you have a flat hierarchy)
Distinguished name of branch of directory where information about users is stored.
ou=CorporateUsers,c=us,o=mycompany
For example: DC=sap, DC=corp
User Group:If you have a flat hierarchy, enter the distinguished name of the branch of your directory where information about the groups of portal users is stored.
If you have groups in a tree hierarchy, enter the distinguished name of the branch of your directory where information about portal users and groups is stored.
ou=CorporateGroups,c=us,o=mycompany
6.Choose Save All Changes to save the entire configuration. Otherwise, choose Restore All Changes to undo all data you have entered only on this tab.
7.After changing settings using the configuration tool, you must restart the J2EE Engine.
rewards if useful........
Minal
2007 Nov 02 7:37 AM
Hi here is the sample we recently used for getting e-mails ID from LDAP distribution lists...
FUNCTION Y_ISA_LDAP_UPDATE.
*"----
""Local interface:
*" IMPORTING
*" VALUE(EMAIL) TYPE AD_SMTPADR
*" TABLES
*" ATTRIBUTES_IN STRUCTURE LDAP_ATII
*" VALUES_IN STRUCTURE LDAP_VALI
*" ET_MESSAGES STRUCTURE CRMT_ISALES_RETURN
*"----
Modification Log
0001 08/02/2004 MFoley Created to update LDAP variables passed in
through attributes_in and values_in
structure based on email id.
*"----
data: dns_out like ldap_dnii occurs 0 WITH HEADER LINE,
SERVERID LIKE LDAPSERVER-SERVERID,
ws_tvarv like tvarv,
ws_attribute_lines(4) type n,
ws_attrs_io_lines(4) type n,
ws_attribute_index(4) type n,
ATTRS_IO like ldap_atii occurs 0 WITH HEADER LINE,
VALUES_IO like ldap_vali occurs 0 WITH HEADER LINE,
ws_attributes_delete like ldap_atii occurs 0 with header line,
search_term type c length 255,
SEARCH_TERM_2 TYPE C LENGTH 255,
FIELD_EXISTS TYPE C LENGTH 1.
data: w_test type n.
w_test = 1.
while w_test = 1.
endwhile.
*system bind----
SELECT SINGLE * FROM TVARV into corresponding fields of ws_tvarv
WHERE NAME = 'Y_ISA_F_ADAM_SERVER'.
SERVERID = WS_TVARV-LOW.
CALL FUNCTION 'LDAP_SYSTEMBIND'
EXPORTING
SERVERID = SERVERID
WRITEREAD = 'W'
WAIT_TIME = 5
EXCEPTIONS
NO_AUTHORIZ = 1
CONFIG_ERROR = 2
NOMORE_CONNS = 3
LDAP_FAILURE = 4
NOT_ALIVE = 5
OTHER_ERROR = 6
OTHERS = 7.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*search for record----
concatenate '(&(objectclass=)(cn=' email '))' into search_term.
clear: dns_out, attrs_io, values_io.
refresh: dns_out, attrs_io, values_io.
CALL FUNCTION 'LDAP_SEARCH'
EXPORTING
BASE = 'ou=Members,o=ADI Internet' "0001
BASE = 'OU=WebAdam,DC=Analog,DC=com' "0001
SCOPE = 2
MODE = 'C'
CROP = 'X'
CROP_DN_ATTR = 'X'
FILTER = SEARCH_TERM
TABLES
DNS_OUT = dns_out
ATTRS_IO = attrs_io
EXCEPTIONS
NO_AUTHORIZ = 1
CONN_OUTDATE = 2
LDAP_FAILURE = 3
NOT_ALIVE = 4
OTHER_ERROR = 5
OTHERS = 6.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
describe table attrs_io lines ws_attrs_io_lines.
if ws_attrs_io_lines = 0.
ET_MESSAGES-NUMBER = '998'.
ET_MESSAGES-ID = 'E'.
ET_MESSAGES-MESSAGE = 'User does not exist in Active Directory'.
ET_MESSAGES-LOG_NO = 'FE'.
APPEND ET_MESSAGES.
*unbind----
CALL FUNCTION 'LDAP_UNBIND'
EXCEPTIONS
CONN_OUTDATE = 1
LDAP_FAILURE = 2
NOT_ALIVE = 3
OTHER_ERROR = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
EXIT.
endif.
loop at attributes_in.
ws_attribute_index = sy-tabix.
read table values_in index ws_attribute_index.
check to see if field already is on Active Directory
field_exists = 'N'.
loop at attrs_io where text = attributes_in-text.
field_exists = 'Y'.
endloop.
if attribute is on active directory update it
if field_exists = 'Y'.
"If value exists, then update it - otherwise, delete
if values_in-text <> ''.
attributes_in-num1 = 2.
attributes_in-num2 = 1.
modify attributes_in.
else.
ws_attributes_delete-text = attributes_in-text.
append ws_attributes_delete.
delete attributes_in.
delete values_in index ws_attribute_index.
endif.
else.
If attribute isn't on active directory create it
if values_in-text <> ''.
" if values exists, then create it - otherwise remove
attributes_in-num1 = 0.
attributes_in-num2 = 1.
modify attributes_in.
else.
delete attributes_in.
delete values_in index ws_attribute_index.
endif.
endif.
endloop.
*CONCATENATE 'CN=' ALIAS ',OU=MEMBERS,O=ADI INTERNET' INTO SEARCH_TERM_2
LOOP AT DNS_OUT.
SEARCH_TERM_2 = DNS_OUT-TEXT.
ENDLOOP.
only execute modify if there's anything to be updated
describe table attributes_in lines ws_attribute_lines.
if ws_attribute_lines > 0.
CALL FUNCTION 'LDAP_MODIFY'
EXPORTING
DN = SEARCH_TERM_2
MODE = 'C'
TABLES
ATTRS_IN = attributes_in
VALUES_IN = values_in
EXCEPTIONS
NO_AUTHORIZ = 1
CONN_OUTDATE = 2
PARAM_ERROR = 3
LDAP_FAILURE = 4
HEXVAL_ERROR = 5
NOT_ALIVE = 6
OTHER_ERROR = 7
OTHERS = 8.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endif.
If any attributes need to be deleted, loop through
them one by one to remove (getting syntax errors when
I try to delete them all at one time).
loop at ws_attributes_delete.
clear: attrs_io, values_io.
refresh: attrs_io, values_io.
attrs_io-text = ws_attributes_delete-text.
attrs_io-num1 = 1.
attrs_io-num2 = 1.
append attrs_io.
CALL FUNCTION 'LDAP_MODIFY'
EXPORTING
DN = SEARCH_TERM_2
MODE = 'C'
TABLES
ATTRS_IN = attrs_io
VALUES_IN = values_io
EXCEPTIONS
NO_AUTHORIZ = 1
CONN_OUTDATE = 2
PARAM_ERROR = 3
LDAP_FAILURE = 4
HEXVAL_ERROR = 5
NOT_ALIVE = 6
OTHER_ERROR = 7
OTHERS = 8.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endloop.
*unbind----
CALL FUNCTION 'LDAP_UNBIND'
EXCEPTIONS
CONN_OUTDATE = 1
LDAP_FAILURE = 2
NOT_ALIVE = 3
OTHER_ERROR = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFUNCTION.
2008 Aug 25 10:32 AM
Hi Jyoti,
I using ECC6.0 and triny to exicute your set code ...but it is giving me error in LDAP_SERCH fm as LDAP_FAILURE...
Plz help me in that .....in your code your are givng
BASE = 'OU=WebAdam,DC=Analog,DC=com'
and i m giving 'CN=SAP_HR_LDAP,CN=Users,DC=DEL,DC=SITE,DC=COM'
is that correct ...frm where i will get the Base information...
Plz help me in that...
Thnx
Rohit
Edited by: Rohit Kumar on Aug 25, 2008 3:02 PM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |