• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3186
  • Last Modified:

Linking Common Access Card (CAC) and Active Directory

I am trying to work with Common Access Card (CAC) and Active Directory on the 2003 Windows Server with IIS 6.0. Once a person accesses my page on the server, code needs to automatically map a Common Access Card's "Identification" number to an individual's Active Directory 2003 account. Please let me know if anyone has tried this before. I am using ASP.NET and C#.

  • 3
  • 3
1 Solution
Dustin HopkinsSenior Web DeveloperCommented:
Do you use CACs to login to AD? Generally AD is configured for CAC login by Setting the User logon name to the EDIPI then setting the pre 2000 logon name to the actual username. Generally to do this you would restrict the site to CAC only, then pull the users windows credentials.
nsdlsandyAuthor Commented:
Thanks for your input.
How can we do this - "Generally to do this you would restrict the site to CAC only, then pull the users windows credentials?"

Dustin HopkinsSenior Web DeveloperCommented:
You need to enable windows authentication. Then Require SSL and require client certificates.
Then only add the CAC Cert Authorities to the CTL(Certificate trust list).

This setup will require the user to select the cac certificate and enter their PIN. Then use page.user.identity.name will pull Domain\username.

Also, this allows you to pull the user's client certificate info which includes the EDIPI
A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

nsdlsandyAuthor Commented:

sorry for the late response. I was trying to see any alternate method but found none so far.
Do you have the code to do the stuff you mentioned in the previous post.

Dustin HopkinsSenior Web DeveloperCommented:
Sorry, I've been quite busy the past week. Here is some code to help.
Note, this code is only relevant after your require client certificates in IIS.
Also, here is a helpful link: http://forums.asp.net/p/1356598/2785315.aspx

Then to configure IIS to re quire Client Certs:

You need to go to IIS Manager->Default Website-> right click and go to Properties->Directory Security->Under Secure Communications section, click on Edit.
>Click require SSL and 128 bit. Then click require client certificates.

If this is a CAC or DoD setup then you must have activclient and tumbleweed installed on the server as well as your dod certificates which you should have if you have an ssl cert issued from C Auth.

Make sure to configure your CTL to only accept the certificates issued for your smart cards.
       HttpClientCertificate cs = Request.ClientCertificate;
        string[] subjectArray = cs.Subject.Split(',');

//Holds the entire contents of the subject line.
        string entireSubjectLine = cs.Subject.ToString();

  	//gets the total length of the subject line
        int subjectLineLength = entireSubjectLine.Length;  

//-10 grabs the start of the 10 digit CAC identifer code for the user.
        int startOfCacIdentifierPosition = subjectLineLength - 10; 

string cacIdentifier = entireSubjectLine.Substring(startOfCacIdentifierPosition, 10);
        string[] arr = subjectArray[5].Split(' ');
        string[] user = arr[1].Split('=');
        StringBuilder sb = new StringBuilder();
        foreach (string field in user)
        sb.Remove(0, 2);
        string str1 = sb.ToString();
        string[] sArr1 = str1.Split('.');
        string lastName = sArr1[0].ToString();
        string firstName = sArr1[1].ToString();
        string MI = sArr1[2].ToString();
        string Id = cacIdentifier; //10 Digit Unique CAC identifier

Open in new window

nsdlsandyAuthor Commented:
This is not the exact solution but it is good enough to get me started.
thanks for been patient as I juggled different stuff at my end.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now