?
Solved

ADSI Authentication to WinNT Provider

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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

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?
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
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…
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.
Suggested Courses
Course of the Month16 days, 2 hours left to enroll

850 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