Last post Jul 05, 2017 11:32 AM by PatriceSc
Jul 05, 2017 04:33 AM|IamGuy84|LINK
Here is my code:
List<KeyValuePair<string, string>> attributeList = new List<KeyValuePair<string, string>>();
string attributeName = attribute.Name;
string attributeVal = attribute.StringValue;
// rest omitted
if (attributeName == "sAMAccountName" || attributeName == "mail" || attributeName == "displayName" || attributeName == "telephoneNumber" || attributeName == "mobile")
attributeList.Add(new KeyValuePair<string, string>(attributeName, attributeVal));
It seems ok but i want to display output like:
"displayName" : "*****"
Is It possible to hide key and value? If yes then how?
I am waiting for your response.
Thanks in advance
Jul 05, 2017 07:19 AM|PatriceSc|LINK
Not sure to get it. Which problem are you trying to solve? By order of preference :
- if I don't want to expose data I would just not expose them. Why to include those fields if you want to show a fake value for them?
- you could show **** at the UI level by design even if you don't get this value from the json payload
- you could use attributeList.Add(new KeyValuePair<string, string>(attributeName, "********")); for those fiels but it could be confusing (in particular if you post back those fake values).
If you need further help we would need perhaps to understand first what you are trying to avoid (for example if the goal is to avoid a clear text transfer over the network you could use https).
Edit: for the serialization try to use a Dictionary rather than a list of key value pairs. It should be serialized as key:value.
Jul 05, 2017 10:15 AM|IamGuy84|LINK
Thank you for quick response.
I tired to use Dictionary key value pair.
Dictionary<string, string> attributeList = new Dictionary<string, string>();
if (attributeName == "sAMAccountName" || attributeName == "mail" .......)
I am getting error message and it says: "Error:An item with the same key has already been added. Key: mail".
Can you plz tell me how to duplicate key?
Jul 05, 2017 10:28 AM|Dmitry Sikorsky|LINK
It is not possible to have duplicated keys in dictionary.
You can use List<KeyValuePair<string, string>> instead.
Jul 05, 2017 11:32 AM|PatriceSc|LINK
Or maybe an array of mail addresses attached to this particular user ?