Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Active Directory

Status
Not open for further replies.

Eduu

Programmer
Feb 9, 2006
17
YU
Has anyone tried programming with the Active Directory Services Interface(ADSI)? I just want to be able to verify that my users exists on my network when they logon with their username and passwords? Any suggestions,links etc?
Thanks
 
Try something like this:

On Error Resume Next

strDomain="MACHINENAME"
strUser="jdoe"

Set oDomain = GetObject("WinNT://" & strDomain)

Set oUser = oDomain.Create ("user", strUser)

If (err.number <> 0) Then
'Users exists on domain because Create method has failed

ELSE
'Handle case for non-existent user here
End If

Set oDomain=Nothing



If the user exists in the domain, then the Create method fails. We check for this by examining the number property of the built in Err object. If the Err.number <> 0 then the user exists. Jamie Gillespie
j-gillespie@s-cheshire.ac.uk
 
Thanks. I have a few problems with this. Firstly, if someone types in a valid username without the correct password, it shouldn't let him in.
I'm not try to validate that the user exists on system but on a network. I'm running Windows 2000.
 

JGillespie,

Also, what if you don't have write to create a user, you will get a number &quot;<>&quot; to 0. This is not a good check for a user.


fengshui_1998
 
Point taken fengshui_1998, overlooked that one. I'm admin for every machine i sit at at work so it has never cropped up before!!

Why not simply use NTFS permissions to grant or deny acces to the file in question then.

OR if you really want to use ADSI then loop through the users on the domain checking for a match ( is a good resource). Problem is though that i don't think ADSI exposes password property for you to read to make a check against (security issue!)

HTH Jamie Gillespie
j-gillespie@s-cheshire.ac.uk
 
If you're wanting your application to actually authenticate the credentials that the user supplies, you can't use the WinNT provider if the user (of the current process) has already logged into the network. (Actually, I think there is a work-around, but the implementation is not very glamarous because it involves changing the user's password to a dummy, then setting it back). For more, see
If you are using a Win2K network, which you appear to be, you can use the LDAP provider. For more, see
Jon Hawkins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top