You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/docs/asciidoc/index.adoc
+60-1Lines changed: 60 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1091,10 +1091,69 @@ The `@Attribute` annotation is used to map object class fields to entity fields.
1091
1091
1092
1092
The `@DnAttribute` annotation is used to map object class fields to and from components in the distinguished name of an entry.
1093
1093
Fields annotated with `@DnAttribute` are automatically populated with the appropriate value from the distinguished name when an entry is read from the directory tree.
1094
+
1095
+
Consider a class with the following annotation:
1096
+
1097
+
[tabs]
1098
+
======
1099
+
Java::
1100
+
+
1101
+
[source,java,role="primary"]
1102
+
----
1103
+
@DnAttribute(name="uid")
1104
+
String uid;
1105
+
----
1106
+
=====
1107
+
1108
+
and a DN like the following:
1109
+
1110
+
====
1111
+
[source,bash]
1112
+
----
1113
+
uid=carla,dc=springframework,dc=org
1114
+
----
1115
+
====
1116
+
1117
+
Then Spring LDAP will populate `uid` using `uid=carla` instead of looking for a `uid` attribute.
1118
+
1119
+
[NOTE]
1120
+
----
1094
1121
Only fields of type `String` can be annotated with `@DnAttribute`. Other types are not supported.
1095
-
If the `index` attribute of all `@DnAttribute` annotations in a class is specified, the DN can also be automatically calculated when creating and updating entries.
1122
+
----
1123
+
1124
+
You can alternatively supply an index like so:
1125
+
1126
+
[tabs]
1127
+
======
1128
+
Java::
1129
+
+
1130
+
[source,java,role="primary"]
1131
+
----
1132
+
@DnAttribute(index=1)
1133
+
String uid;
1134
+
1135
+
@DnAttribute(index=0)
1136
+
String department;
1137
+
----
1138
+
=====
1139
+
1140
+
which is handy for DNs that have multiple components:
Using an `index` also allows Spring LDAP to compute the DN for you when creating or locating an entity for update or deletion.
1096
1150
For update scenarios, this also automatically takes care of moving entries in the tree if attributes that are part of the distinguished name have changed.
1097
1151
1152
+
[NOTE]
1153
+
----
1154
+
Note that while both attributes are present on `@DnAttribute`, if `index` is specified, then `name` is ignored.
1155
+
----
1156
+
1098
1157
The `@Transient` annotation indicates that the field should be ignored by the object directory mapping and not mapped to an underlying LDAP property. Note that if a `@DnAttribute` is not to be bound to an `Attribute`. That is, it is only part of the Distinguished Name and not represented by an object attribute. It must also be annotated with `@Transient`.
0 commit comments