public override PSCredential PromptForCredential()

in dotNet/PsEdge/PsHostUI.cs [213:260]


        public override PSCredential PromptForCredential(string caption, string message, string userName, string targetName,
            PSCredentialTypes allowedCredentialTypes, PSCredentialUIOptions options)
        {
            var promptInput = new EdgePromptInput()
            {
                Caption = caption,
                Message = message,
                FieldDescriptions = new List<EdgeFieldDescription>()
            };

            promptInput.FieldDescriptions.Add(new EdgeFieldDescription()
            {
                Name = "UserName",
                IsArray = false,
                IsSecureString = false,
                Type = "String"
            });

            promptInput.FieldDescriptions.Add(new EdgeFieldDescription()
            {
                Name = "Password",
                IsArray = false,
                IsSecureString = true,
                Type = "SecureString"
            });

            var output = this.promptHandler(promptInput).Result;
            var outputDict = (IDictionary<string, object>) output;
            var user = string.Empty;
            var password = string.Empty;

            foreach (var entry in (object[]) outputDict["Results"])
            {
                var entryDict = (IDictionary<string, object>) entry;

                if (entryDict["Name"].Equals("UserName"))
                {
                    user = (string) entryDict["Value"];
                }

                if(entryDict["Name"].Equals("Password"))
                {
                    password = (string)entryDict["Value"];
                }
            }

            return new PSCredential(user, ToSecureString(password));
        }