Solved

ADSI Authentication to WinNT Provider

Posted on 2004-03-26
2
1,784 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 500 total points
ID: 10693043
Are you trying to do it like this: http://www.eggheadcafe.com/articles/20010126.asp ?
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

740 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