Solved

ADSI Authentication to WinNT Provider

Posted on 2004-03-26
2
1,764 Views
Last Modified: 2012-08-14
I want to authenticate  a user from my web page (.NET) using ADSI. I think I've got the code correct, but I get the following error:

Unspecified Error
System.Runtime.InteropServices.COMExeption

It seems to bom out when the OpenDSObject method is called. Here's the code

Dim objADSI, strUsername, strPassword, strDomain
Dim strADsNamespace
Dim objADSINamespace
Dim blnFound

strUsername = " Trim(txtUsername.Text)"
strPassword = Trim(txtPassword.Text)

strDomain = "MYDOMAIN"
objADSI = GetObject("WinNT://" & strDomain)

strADsNamespace = Left("WinNT://" & strDomain, InStr("WinNT://" & strDomain, ":"))

objADSINamespace = GetObject(strADsNamespace)
bjADSI = objADSINamespace.OpenDSObject("WinNT://" & strDomain, strUsername, strPassword, 0)

If Err.Number <> 0 Then
    blnFound = False
Else
    blnFound = True
End If

Thanking you
       
0
Comment
Question by:hattinnh
  • 2
2 Comments
 
LVL 7

Expert Comment

by:TheKenman
ID: 10693042
You're missing some set statements, and I gave you some error handlers to help as well. I think your code should be something like this:

strDomain = "MYDOMAIN"
strADsPath = "WinNT://" & strDomain
strADsNamespace = Left(strADsPath, InStr(strADsPath, ":"))

On Error Resume Next
Set objADSI = GetObject(strADsPath)
   If Err.Number <> 0 Then
        response.write "Error with Set objADSI = GetObject(strADsPath)<BR>strADsPath: " & strADsPath
        response.end
   End If
Set objADSINamespace = GetObject(strADsNamespace)    
   If Err.Number <> 0 Then
        response.write "Error with Set objADSINamespace = GetObject(strADsNamespace)<BR>strADsNamespace: " & strADsNamespace
        response.end
   End If
Set objADSI = objADSINamespace.OpenDSObject(strADsPath, strUsername, strPassword, 0)
   If Err.Number <> 0 Then
        response.write "Error with Set objADSI = objADSINamespace.OpenDSObject(strADsPath, strUsername, strPassword, 0)<BR>strADsPath: " & strADsPath & "<BR>strUsername: " & strUsername & "<BR>strPassword: " & strPassword
        response.end
   End If
0
 
LVL 7

Accepted Solution

by:
TheKenman earned 500 total points
ID: 10693043
Are you trying to do it like this: http://www.eggheadcafe.com/articles/20010126.asp ?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
DNS, website, godaddy 6 77
Is this responsive table set up right for all browsers 4 63
Angular JS form 8 45
Form Processing in PHP 11 32
Read about why website design really matters in today's demanding market.
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now