Solved

ADSI Authentication to WinNT Provider

Posted on 2004-03-26
2
1,755 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Joomla Website Malfunction 9 52
Swiper slider stops between pages 11 32
Video on my site 4 27
Editing login page in zencart. 2 14
Problem to be resolved in this article Currently, development of website and web application can be done without writing thousands of lines of programming code by hand. Description This can be done through by using a open source framework such …
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video teaches users how to migrate an existing Wordpress website to a new domain.

757 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

24 Experts available now in Live!

Get 1:1 Help Now