Creating custom user attributes in Active Directory using JNDI - java

I am attempting to create a custom attribute that can be assigned to an existing Active Directory user in my domain. I am not fully aware of how to achieve this. It is my understanding that once the attribute has been created, I can assign it to the user via:
mods[0] = new ModificationItem(DirContext.ADD_ATTRIBUTE, new BasicAttribute("attributeName", "attributeValue"))
ctx.modifyAttributes(userDN, mods)
Any information is appreciated.

Not sure what you want to do.
But Active-Directory is a Directory, so it use a SCHEMA to define which attributes can be used in an object. This means that you can modify (add, delete, replace) the value of an attribut that exists (in the SCHEMA) for a given class, but can'nt add a custom attribut to a class without modifying the SCHEMA.

Related

Search User based on Custom attribute value in OIM

I have created one custom attribute and updating its value to 'true'. Now I am trying to fetch all the user for which custom attribute value is 'true'. I am trying to use the below API but in that I am able to pass only OOTB attributes. Please help.
List listOfStatus = new ArrayList();
listOfStatus.add("true");
SearchCriteria statusSearchCriteria = new SearchCriteria(UserManagerConstants.AttributeValues.USER_STATUS_ACTIVE.getId(), listOfStatus, SearchCriteria.Operator.IN);
You'd need to mark the attribute as "Searchable" to be able to search against it. In the API you will provide then this attribute name.

where is Session's attributes are saved

I'm trying to add an attribute to session, in a huge pre-realized project (web application project using Java and Tapestry framework), but I don't know where the attribute are saved, so that I can declare a new attribute for Session
in fact , I found out that attributes are added like variable into the session declaration, using just session.setAttribute("Attribute", name)
and then it will be saved, and you can access it using session.getAttribute(name)

Hibernate's PhysicalNamingStrategy's toPhysicalSchemaName does not get called

I'm using Hibernate and trying to externalize the entity's table and column names to a .properties file. I've implemented the PhysicalNamingStrategy to map the entity properties and when executed everything works correctly (i.e., the methods toPhysicalTableName and toPhysicalColumnName get called for the table name and every mapped property, respectively).
However the toPhysicalSchemaName doesn't get called, even if I provide the annotation #Table(schema="SCHEMA_NAME"). The documentation says that
The PhysicalNamingStrategy will be applied regardless of whether the attribute explicitly specified the column name or whether we determined that implicitly. The ImplicitNamingStrategy would only be applied if an explicit name was not given.
I do not know if this applies to the schema name too. The toPhysicalSchemaName just won't get called no matter what I do. Should I be configuring the schema name differently for this to work?
Appreciate the help!
After some debugging found out that the hibernate-core 5.2.2.Final incorrectly creates the namespace. The org.hibernate.boot.model.relational.Namespace.java constructor has the following line
this.physicalName = new Namespace.Name(
database.getPhysicalNamingStrategy()
.toPhysicalCatalogName(name.getCatalog(), database.getJdbcEnvironment()),
database.getPhysicalNamingStrategy()
.toPhysicalCatalogName(name.getSchema(), database.getJdbcEnvironment())
);
The Name constructor expects the second argument to be the schema name, but the catalog gets passed again. Instead it should have been
this.physicalName = new Namespace.Name(
database.getPhysicalNamingStrategy()
.toPhysicalCatalogName(name.getCatalog(), database.getJdbcEnvironment()),
database.getPhysicalNamingStrategy()
.toPhysicalSchemaName(name.getSchema(), database.getJdbcEnvironment())
);
This is fixed in hibernate-core-5.2.10.Final.

Saving Object with path in Spring MVC

I yould like to know if it is possible to directly save an object in a hibernate/spring/maven project with path. So my class has an object attribute "Category". In the form I have a select. If I put different Category objects as Value in select and I link the select with form:select and path to the Category attribute, will it save it automatically ? Otherwise I would have to get the ID, get back the object from the ID in my controller and then set the Category attribute with the setter in order to save the whole thing.
Thanks

Change update insert attributes programmatically

I would like to know if it's posible to change the insert and update attributes of a property defined in the mapping of a Class.
This is because in one scenario I need to update a property (or properties), but not in another, it's posible?
Thanks in advance
EDIT: Lets say that I've the Class User(with name, surname and loginDate), when the user logs into the app, I need to update only loginDate. But the administrator of the system must be able to edit the name and the surname of the User.
The only other solution that ocurrs to me is to use HQL for a Update (or in the worst case SQL), but I want if it's posible to modify that attributes.
EDIT 2: after reading Java persistence with hibernate and some forum threads I found that once the sessionFactory is created the mappings are immutables, and though You can change the properties programmatically, You need to create a new sessionFactory
// this is what the login screen calls
void updateLoginDate(Date date)
{
User user = session.get(User.class);
user.setDate(date);
session.Flush();
}
and in the mapping you could specify dynamicUpdate = true on the class so that the generated sql only updates columns which have changed

Categories