How to modify IPv4 address using LDIF Files

233 views Asked by At

enter image description hereI need to change an IPv4 address to multiple IPv4 addresses using LDIF file. The original LDIF file which was used to create the HSS ESM is the following:

dn: HSS-EsmImsi=312720000000207,HSS-EsmSubscriptionId=BR-02061969,
    HSS-EsmSubscriptionContainerName=HSS-EsmSubscriptionContainer,
    applicationName=HSS_ESM,nodeName=bnyrgvhss1
    changeType: modify
    add: HSS-EsmUserProfileId
    HSS-EsmUserProfileId: HSS-EsmProfile_APCCI_METERING
    -
    add: HSS-EsmUserIpV4Address
    HSS-EsmUserIpV4Address: 4$10.11.12.13
    -
    add: HSS-EsmMsisdn
    HSS-EsmMsisdn: +1 234 567 8901
    -

Now, I need to do 2 things:

  1. Change the IPv4 address (e.g. 10.13.15.17).
  2. Modify the HSS ESM User Object Class, so HSS-EsmUserIpV4Address will store multiple IPv4 addresses.

According to Erickson's - ESM LDAP Interface Description this should be done with a string in the following format: [contextId1]$[IPv4-Address1]\n [contextId2]$[IPv4-Address2]\n ...[contextIdNN]$[IPv4-AddressNN]\n.

Legend:

  1. [contextId] datatype is uint32.
  2. $ is a CONSTANT (US Dollar sign).
  3. [IPv4-Address] IP Addresses are dotted-decimal of string datatype, e.g. 10.12.14.16.
  4. \n is a CONSTANT (New-Line).

I am new to LDAP and will appreciate any help on how the LDIF file should be to so that HSS-EsmUserIpV4Address will store, for example, the following IPv4 addresses:

2$159.10.1.20
7$159.10.1.21
8$159.10.1.22

I tried to change the LDIF file to do Delete and Add like this:

... (the original code)...
changeType: modify
delete: HSS-EsmUserProfileId
-
add: HSS-EsmUserProfileId
HSS-EsmUserProfileId: 2$159.10.1.20\n7$159.10.1.21\n8$159.10.1.22\n
-

But, it didn't work (no error messages, just no change).

I will appreciate any help, I am here (at work) to stay until I make this happen.

2

There are 2 answers

2
user207421 On BEST ANSWER
add: HSS-EsmUserProfileId
HSS-EsmUserProfileId: 2$159.10.1.20\n7$159.10.1.21\n8$159.10.1.22\n

First, you're changing the wrong attribute. It should be

add: HSS-EsmUserIpV4Address
HSS-EsmUserIpV4Address: 2$159.10.1.20\n7$159.10.1.21\n8$159.10.1.22\n

and you may have damaged the original value of this attribute, so you need to put it back:

delete: HSS-EsmUserProfileId
add: HSS-EsmUserProfileId
HSS-EsmUserProfileId: HSS-EsmProfile_APCCI_METERING

Second, I don't know where you got this format with \n separators from. I don't see it in the documentation you cited. The normal LDIF syntax for multiple attribute values would be:

add: HSS-EsmUserIpV4Address
HSS-EsmUserIpV4Address: 2$159.10.1.20
HSS-EsmUserIpV4Address: 7$159.10.1.21
HSS-EsmUserIpV4Address: 8$159.10.1.22

Note that this will preserve the prior value starting with 4$, unless you previously used delete: as above.

1
Binyamin Regev On

Thank you EJP, you have put me on the track to the answer and the reason for my previous mistake.

The solution: in the LDIF file use changeType: modify with replace, or delete.

And the correct LDIF file should be:

dn: HSS-EsmImsi=312720000000207,HSS-EsmSubscriptionId=BR-02061969,
HSS-EsmSubscriptionContainerName=HSS-EsmSubscriptionContainer,
applicationName=HSS_ESM,nodeName=bnyrgvhss1
changeType: modify
add: HSS-EsmUserProfileId
HSS-EsmUserProfileId: HSS-EsmProfile_APCCI_METERING
-
delete: HSS-EsmUserIpV4Address
-
add: HSS-EsmUserIpV4Address
HSS-EsmUserIpV4Address: 1$159.10.1.20
HSS-EsmUserIpV4Address: 2$159.10.1.21
HSS-EsmUserIpV4Address: 3$159.10.1.22
-
add: HSS-EsmMsisdn
HSS-EsmMsisdn: +12345678901
-

This will delete a specific value from the attribute and add 2 others:

dn: HSS-EsmImsi=312720000000207,HSS-EsmSubscriptionId=BR-02061969,
HSS-EsmSubscriptionContainerName=HSS-EsmSubscriptionContainer,
applicationName=HSS_ESM,nodeName=bnyrgvhss1
changeType: modify
delete: HSS-EsmUserIpV4Address
HSS-EsmUserIpV4Address: 2$159.10.1.20
-
add: HSS-EsmUserIpV4Address
HSS-EsmUserIpV4Address: 1$159.10.1.23
HSS-EsmUserIpV4Address: 2$159.10.1.24
-

The following code will delete all instances of the attribute and add the attribute again with 3 other values:

dn: HSS-EsmImsi=312720000000207,HSS-EsmSubscriptionId=BR-02061969,
HSS-EsmSubscriptionContainerName=HSS-EsmSubscriptionContainer,
applicationName=HSS_ESM,nodeName=bnyrgvhss1
changeType: modify
delete: HSS-EsmUserIpV4Address
-
add: HSS-EsmUserIpV4Address
HSS-EsmUserIpV4Address: 1$159.10.1.25
HSS-EsmUserIpV4Address: 2$159.10.1.26
HSS-EsmUserIpV4Address: 3$159.10.1.27
-

I found this on How To Use LDIF Files to Make Changes to an OpenLDAP System.

Screen shot of the attached link

Thank you for @EJP for his HUGE help.