What is a Primary Token?
The Active Directory (AD) relies on the security mechanism of the Windows 2000 server. To access most information in the AD, you must provide credentials to the Windows 2000 server when requesting the AD information. The credentials you provide must be in a primary token, which just means that the IIS server has a password (not just a hash of the password) to pass to the AD.
back to the topDouble-Hop Issue
The double-hop issue is when the ASPX page tries to use resources that are located on a server that is different from the IIS server. In our case, the first "hop" is from the web browser client to the IIS ASPX page; the second hop is to the AD. The AD requires a primary token. Therefore, the IIS server must know the password for the client to pass a primary token to the AD. If the IIS server has a secondary token, the
NTAUTHORITY\ANONYMOUS account credentials are used. This account is not a domain account and has very limited access to the AD.
The double-hop using a secondary token occurs, for example, when the browser client is authenticated to the IIS ASPX page by using NTLM authentication. In this example, the IIS server has a hashed version of the password as a result of using NTLM. If IIS turns around and passes the credentials to the AD, IIS is passing a hashed password. The AD cannot verify the password and, instead, authenticates by using the
NTAUTHORITY\ANONYMOUS LOGON.
On the other hand, if your browser client is authenticated to the IIS ASPX page by using Basic authentication, the IIS server has the client password and can make a primary token to pass to the AD. The AD can verify the password and does authenticate as the domain user.
For more information, click the following article number to view the article in the Microsoft Knowledge Base:
264921 How IIS authenticates browser clients
back to the topHow to Acquire a Primary Token
If the IIS server has a primary token to pass on, the IIS server can pass a primary token to the AD on behalf of the client requesting the ASPX page. To acquire a primary token by using ASPX, use one of the following methods.
Method A
When the Web.config file is set to
identity impersonate="true"/ and
authentication mode="Windows", use the
Anonymous account with the following settings:
- On the ASPX page, set the security mechanism to
Anonymous only. - Clear the Allow IIS to control the password check box.
- Set the Anonymous account to be a domain user.
Method B
When Web.config and Machine.config are set as follows:
- When Web.config is set to identity impersonate="false"/ and authentication mode="Windows"
- When Machine.config is set to processModel username=Domain\username,password=secret
- If identity impersonate="false"/ in the Web.config file, the credentials of the Base process are used. When you supply a domain user and password, you make it possible for IIS to pass a primary token to the AD.
back to the topError That You May Receive If You Do Not Have a Primary Token
If the code works when you browse to it from the development machine that is a Web server, but the code does not work when other Web clients access the pages, you may receive an error message that is similar to one of the following:
"Failed: System.Runtime.InteropServices.COMException (0x80005000): Unknown error (0x80005000) at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)"
"The specified directory service attribute or value does not exist"
back to the topTroubleshoot the Double-Hop Issue
Use one of the following methods to troubleshoot the double-hop issue.
Quick Test
To quickly determine whether this is a permissions issue, follow these steps:
- Set the ASPX page security mechanism to use Basic only.
- Use a client to browse to the ASPX page, and then provide domain credentials when prompted.
If this works, you can conclude that the double-hop issue is probably the problem.
Test Your Code
Another good troubleshooting test for any IIS ASPX issue when you access the AD involves taking your ASPX code out of the IIS environment and running it as a script file on the IIS server itself. Follow these steps:
- Log on to the IIS server as the domain account that your browser was trying to use, and then run the code.
This test removes the IIS server from the environment and helps you narrow down the problem.
- To determine whether this is a double-hop issue, turn on auditing for directory service objects.
For more information about how to do this for the Active Directory, click the following article number to view the article in the Microsoft Knowledge Base:
232714 How to enable auditing of Directory Service access
After you turn on logging, events are written to the security event log.
If this is your issue, you can find events in the security event log that are similar to the following:
Event Type: Success Audit
Event Source: Security
Event Category: Directory Service Access
Event ID: 565
Date: 3/27/2002
Time: 3:21:41 PM
User: NT AUTHORITY\ANONYMOUS LOGON
Computer: TESTDC
Description:
Object Open:
Object Server: DS
Object Type: user
Object Name: CN=Users,DC=corp,DC=com
New Handle ID: 0
Operation ID: {0,68019232}
Process ID: 264
Primary User Name: TESTDC$
Primary Domain: TESTDOM
Primary Logon ID: (0x0,0x3E7)
Client User Name: ANONYMOUS LOGON
Client Domain: NT AUTHORITY
Client Logon ID: (0x0,0x40DE417)
Accesses READ_CONTROL
Privileges -
Properties:
Note: The directory service has been contacted as the anonymous user. This is because the credentials of the Web user cannot be correctly conveyed to the directory service.
For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
264921 How IIS authenticates browser clients
283201 How to use delegation in Windows 2000 with COM+
For more information, click the following article number to view the article in the Microsoft Knowledge Base:
317012 Process and request identity in ASP.NET
back to the top