2

I spent time creating this in PowerShell only to realize I need to do this in C# with a simple EXE that will create this URL and launch the browser to that URL. Basically it's grabbing the locally logged in users email address from AD and their computer name and submitting it to another form with JSON.

    $email = ([adsi]"LDAP://$(whoami /fqdn)").mail  
    $workstation =  $env:computername

    $url = 'https://www.cognitoforms.com/SupportRequestForm?entry={{"CreateSupportTicket":{{"Workstation":"{0}","YourEmailAddress":"{1}","ConfirmEmail":"{1}"}}}}' -f $workstation, $email.value

Could someone help me out in converting this to C#?

1 Answer 1

3

I don't have Active Directory installed here for testing but I hope this help. For starters add a reference to System.DirectoryServices.AccountManagement in References node of Solution Explorer before including using System.DirectoryServices.AccountManagement; in your code. Then try this code:

string email = UserPrincipal.Current.EmailAddress;
string url = string.Format("https://www.cognitoforms.com/SupportRequestForm?entry={{\"CreateSupportTicket\":{{\"Workstation\":\"{0}\",\"YourEmailAddress\":\"{1}\",\"ConfirmEmail\":\"{1}\"}}}}", Environment.MachineName, email);
Console.WriteLine(url);

If you need fqdn use this:

string fdqn = System.Net.Dns.GetHostEntry(Environment.MachineName).HostName;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.