on 04-06-2009 5:35 PM
Hello,
I am using this code to set and get custom ume attributes:
String[] phoneExt={wdContext.currentInputValuesElement().getPhone_Ext().toString().trim()};
newUser.setAttribute("com.sap.security.core.usermanagement","phone_ext", phoneExt);
String[] phoneExt = searchedUser.getAttribute("com.sap.security.core.usermanagement","phone_ext");
String ext = "";
for(int j=0; j<phoneExt.length; j++){
ext = phoneExt[j];
break;
}
This doesn't seem to work. Can anybody let me know the correct way.
Hi Tony,
I have encountered a problem similar to yours and Michael is right getAttributeNameSpaces really helps. Also, try to use DEFAULT_NAMESPACE constant.
Hope it helps.
Regards,
Erwin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Michael,
I am using this code:
//get custom phone_ext attribute
String namespaces[] = searchedUser.getAttributeNamespaces();
String ns = null;
for (int i = 0; i < namespaces.length; i++) {
if (i > 0)
ns = namespaces[ i ];
String attrNames[] = searchedUser.getAttributeNames(ns);
if (ns != null){
g_message_manager.reportSuccess("NS: " + ns);
if(ns.equals("com.sap.security.core.usermanagement")){
for (int j = 0; j < attrNames.length; j++) {
if(attrNames[j].equals("phone_ext")){
g_message_manager.reportSuccess("\n" + attrNames[j] + " = ");
Object attr[] = searchedUser.getAttribute(ns, attrNames[j]);
for (int k = 0; k < attr.length; k++){
if(!(null == attr[k])|| !(attr[k].toString().length() == 0))
searchResult.setPhone_Ext(attr[k].toString());
break;
}
}else
continue;
}
}else
continue;
}
}
This doesn't seem to work?
Thanks
Tony
Here is the list of Name spaces when I ran the DC
NS: com.sap.security.core.usermanagement.relation
NS: com.sap.security.core.usermanagement
NS: com.sap.security.core.usermanagement.relation
NS: $inverse_usermapping$
NS: http://sapportals.com/xmlns/cm
NS: com.greenheck.usermgt
NS: $usermapping$
NS: $inverse_usermapping$
NS: $usermapping$
I am able to set this custom ume attribute "phone_ext" and I can see it in the user administration (Customized Information). Problem is I can't somehow read it!
Thanks
Tony
The namespace is not null. Here is all the attributes, but I do not see my custom attribute "phone_ext"
Before entering attribute: uniquename
Before entering attribute: office_num
Before entering attribute: displayname
Before entering attribute: jobtitle
Before entering attribute: company
Before entering attribute: locale
Before entering attribute: lastname
Before entering attribute: LAST_MODIFIED_BY
Before entering attribute: dn
Before entering attribute: kpnprefix
Before entering attribute: PRINCIPAL_MODIFY_DATE
Before entering attribute: krb5principalname
Before entering attribute: firstname
Before entering attribute: description
Before entering attribute: email
But I am using the same namespace "com.sap.security.core.usermanagement" to set the custom attribute "phone_ext"
Here is the list of custom attributes in configtool under ume.admin.addattrs: "krb5principalname;kpnprefix;dn;com.greenheck.usermgt:office_num;phone_ext"
What could be wrong.
Thanks
Tony.
It's strange that office_num is there, but not phone_ext. Is it possible to put phone_ext in the same namespace as office_num and see if this helps?
Also, I assume the first user you're looking up has that attribute? The last time I looked at working with reading attributes it only returned the attribute list for the first user I accessed...
>>>>Is it possible to put phone_ext in the same namespace as office_num and see if this helps?
I think I am sure both are under "com.sap.security.core.usermanagement".
The only difference is office_num is mentioned in the configtool as com.greenheck.usermgt:office_num . I tried the same with phone_ext , that is used the value in configtool as com.greenheck.usermgt:phone_ext. But I couldn't set the value using this code:
String phoneExt[] ={wdContext.currentInputValuesElement().getPhone_Ext().toString().trim()};
newUser.setAttribute("com.sap.security.core.usermanagement","phone_ext", phoneExt);
So I had to use just "phone_ext" instead of com.greenheck.usermgt:phone_ext
If the user doesn't have a value for the custom attribute, it must alteast return the attribute name (and maybe null for the attribute value). In my case it doesn't even show the attribute name when I print all the attributes under the namespace "com.sap.security.core.usermanagement".
It's interesting that your earlier listing of namespaces showed the com.greenheck.usermgt.
In relation to returning the attribute name and maybe a null value even if there isn't a value, that is exactly what I expected, but it didn't happen! Only those attributes with values are being returned.
The syntax for custom attributes says that they can optionally have a namespace plus :. I think you need to pass this value instead of "com.sap.security.core.usermanagement" when using the get/set attribute.
Hi Michael,
You are right. I realized that I didn't do the portal configuration right for the custom attribuate "com.greenheck.usermgt:phone_ext".
The help document only shows configuration for just the name and not the "name along with namespace"
Can you tell me how should I configure com.greenheck.usermgt:phone_ext on the portal. (I already configured it on the configtool and restarted the server. I could see it in user admin under customized information).
Thanks
Tony.
Hi Tony,
Glad to hear that your problem is solved. I did not realized right away that you are working for Greenheck. Actually, I wrote a program for Greenheck, way back in 2004, which is similar to yours.
Regards,
Erwin
P.S., please extend my regards to Rob and John.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For debussing purposes, you might want to use .getAttributeNamespaces() to get the namespaces and then iterate through the namespaces and use getAttributeNames to get the known attribute names. Make sure phone_ext is there.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
How can I read the custom ume attribute. I am able to set the custom ume attribute value using this code:
String[] phoneExt={wdContext.currentInputValuesElement().getPhone_Ext().toString().trim()};
newUser.setAttribute("com.sap.security.core.usermanagement","phone_ext", phoneExt);
Can anyone provide the code on how to read the value of custom attribute.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.