I need to retrive resource object owners and then set that owner to accountgroup owner . but in my Obj owners there are list of emails as owner… how do i grab identity from email
Currentcode:
if (accountGroup == null) {
return null;
}
Identity defaultOwner = context.getObjectByName(Identity.class, "Azure Default Owner");
Identity currentOwner = accountGroup.getOwner();
List ownerList = (List) obj.getAttribute("owners");
if (ownerList == null || ownerList.isEmpty()) {
log.error("No owners found for obj.");
return null;
} else {
log.error("Owners found: " + ownerList);
}
String objOwner1 = (String) ownerList.get(0);
Identity objOwner = context.getObjectByName(Identity.class, objOwner1);
String displayName = accountGroup.getDisplayName();
if (accountGroup.isRequestable()) {
if (displayName != null && displayName.startsWith("AAD")) {
if (currentOwner == null) {
if (objOwner != null) {
accountGroup.setOwner(objOwner);
} else {
accountGroup.setOwner(defaultOwner);
}
}
}
}
else
{
if (displayName != null && displayName.startsWith("AAD")) {
if (currentOwner == null) {
if (objOwner != null) {
accountGroup.setOwner(objOwner);
accountGroup.setRequestable(false);
} else {
accountGroup.setOwner(defaultOwner);
accountGroup.setRequestable(false);
}
}
}
}
return accountGroup;
so problem is i get email as owner so how do i retrieve identity from that email. This is my log output
Owners ad found: [[email protected], [email protected]]