Issue
I want to convert Attribute
s to String
so that I can trim and get a substring of the attribute value.
Here is my code:
Attribute attrs = match.getAttributes();
NamingEnumeration e = attrs.getAll();
System.out.println(attrs.get("cn"));
System.out.print(attrs.get("uniqueMember"));
unique_members[i] = attrs.get("uniqueMember");
I am facing an error in the last line where I want to store the value of uniqueMember
to the unique_members
array. Error:
Type mismatch: cannot convert from Attribute to String
I have tried the following so far:
unique_members[i] = (String)attrs.get("uniqueMember");
It doesn't solve the issue and I am getting error:
Cannot cast attribute to String.
Solution
Use unique_members[i] = attrs.get("uniqueMember").toString()
to convert the attribute value to a string.
For more informationens see the javadoc of BasicAttribute or javax.naming.directory.Attribute
Answered By - Jens Answer Checked By - Marie Seifert (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.