cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to access custom UME attributes.

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Erwin,

Can you please be more specific on how to use getAttributeNameSpaces.

Thanks

Tony.

Former Member
0 Kudos

It's a method that you invoke to return the list of naemspaces for an IUser object. It returns a string array.

Former Member
0 Kudos

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

Former Member
0 Kudos

I think this logic only works if the namespace is the standard one. If you don't specify a namespace when you add your custom attributes to the UME parameter, I don't think it takes the standard one.

What values of namespace were reported when you ran the component?

Former Member
0 Kudos

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

Former Member
0 Kudos

Maybe the namespace is null!

Former Member
0 Kudos

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.

Former Member
0 Kudos

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...

Former Member
0 Kudos

>>>>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".

Former Member
0 Kudos

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.

Former Member
0 Kudos

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"

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/50018d40-d370-2910-3ba7-aa83038d...

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.

Former Member
0 Kudos

That is quite an old document. I normally go to help.sap.com and search from there.. This page (http://help.sap.com/saphelp_nw70ehp1/helpdata/en/44/0316d50bbe025ce10000000a1553f7/frameset.htm) shows the syntax for custom attributes.

I don't know much more than is covered in the help

Answers (2)

Answers (2)

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.