?
Solved

ADSI Authentication to WinNT Provider

Posted on 2004-03-26
2
Medium Priority
?
1,792 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 total points
ID: 10693043
Are you trying to do it like this: http://www.eggheadcafe.com/articles/20010126.asp ?
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

752 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