473,387 Members | 3,781 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

VB.NET App +ADS +DirectoryEntry/Searcher +AuthenticationTypes.Secure

Hi everyone,

Sorry for cross posting, but I wanted to try and put this where it would
be more visible to everyone... :-)

I need to find a way to be able to search for entries in our ADS tree. I
have it working, but I have to pass it my username/password in order to
search it. What I would like to do is pass the username/password to the
DirectoryEntry as parameters without having to hard code a
username/password. I know how to get the username, but how can I pass the
password (i.e. how can I get the password in order to pass it?). For
example:

strUsername = "UserA"
strAuthUsername = "Admin" <--- Hard coded = BAD
strAuthPassword = "Password" <--- Hard coded = BAD
strDomain = "ADS"
strServer = "ads.somewhere.com"
strFilter = ""

Public Shared Function GetUser_DirectoryEntry(ByVal strUsername As
String, ByVal strAuthUsername As String, ByVal strAuthPassword As String,
ByVal strDomain As String, ByVal strServer As String, ByVal strFilter As
String) As DirectoryEntry
Dim strLoginName As String = String.Format("{0}\{1}",
strDomain.Trim, strAuthUsername.Trim)
Dim deSearchRoot As New
DirectoryEntry(String.Format("LDAP://{0}", strDomain.Trim), strLoginName,
strAuthPassword.Trim, AuthenticationTypes.Secure)
Dim de As DirectoryEntry

Try
Dim dsUser As DirectorySearcher = New
DirectorySearcher(deSearchRoot,
String.Format("(&(objectCategory=person)(sAMAccoun tName={0}))",
strUsername.Trim))
Dim srcUser As SearchResultCollection = dsUser.FindAll()
If IsNothing(srcUser) Then
Throw New Utilities.ExceptionHandler("Could not find
user in ADS tree")
Else
de = srcUser(0).GetDirectoryEntry
End If
Catch ex As Exception
Return Nothing
End Try
Return de
End Function

Thanks for any assistance!

Chad
Nov 19 '05 #1
2 1267
On Wed, 5 Oct 2005 11:57:17 -0500, "Chad Beckner" <cb******@iupui.edu>
wrote:
username/password. I know how to get the username, but how can I pass the
password (i.e. how can I get the password in order to pass it?). For
example:


Hi Chad,

Are you saying you want to retrieve a user's password given thier
username? You won't find a way to do that, but you could store the
username and password in the .config or another configuration file in
an encrypted form.

In ASP.NET you could also impersonate a fixed identity by specifying a
username / password in web.config (and this section also supports
encryption). Impersonation will work if the identity is trusted on the
other domain.

--
Scott
http://www.OdeToCode.com/blogs/scott/

Nov 19 '05 #2
No, I don't want to retrieve it, but be able to "use" it to query ADS based
on "their" credentials, instead of having hard coded username & password.

P.S. This "function" will also be run in ASP.NET, but I also need this to
work in a WinForm VB.NET app. :-)

Chad

"Scott Allen" <sc***@nospam.odetocode.com> wrote in message
news:4s********************************@4ax.com...
On Wed, 5 Oct 2005 11:57:17 -0500, "Chad Beckner" <cb******@iupui.edu>
wrote:
username/password. I know how to get the username, but how can I pass the
password (i.e. how can I get the password in order to pass it?). For
example:


Hi Chad,

Are you saying you want to retrieve a user's password given thier
username? You won't find a way to do that, but you could store the
username and password in the .config or another configuration file in
an encrypted form.

In ASP.NET you could also impersonate a fixed identity by specifying a
username / password in web.config (and this section also supports
encryption). Impersonation will work if the identity is trusted on the
other domain.

--
Scott
http://www.OdeToCode.com/blogs/scott/

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sezgin Rafed | last post by:
Hi everyone, I need to select Users from 2 Domains - one the User has logged into and a second one, which is a trusted Domain. There is no problem selecting Users from the Domain the User has...
2
by: Jessica | last post by:
When I create a single LDAP ActiveDirectory user and use DirectoryEntry.Invoke("SetPassword"...), the user is created and the password is set with no problems. However, when I try to add more...
1
by: kenguil | last post by:
I'm hoping that this is the right group to post this to and that someone will have an answer to this. Environment: 1) Laptop joined to domain "foo.com", logged in using cached credentials 2)...
2
by: Chad Beckner | last post by:
Hi everyone, Sorry for cross posting, but I wanted to try and put this where it would be more visible to everyone... :-) I need to find a way to be able to search for entries in our ADS tree. ...
6
by: huzz | last post by:
How do i create a directory entry to access a user's details such as their email address. Here are the object structure. domain.co.uk | |Computer Services - Type (OU) | |Cliff Saran - Type...
0
by: Tulgaa | last post by:
i use following code: -------------------------------------- private sub ShareFolder() Dim ct As New DirectoryEntry("WinNT://" + SystemInformation.ComputerName + "/LanmanServer")...
5
by: Michael Howes | last post by:
I'm writing a utility to manage a machines *local* accounts in c# I am getting all the users in a specific Group just fine but when I want to get some of the information on each user from their...
0
by: apondu | last post by:
Hi I have a query, i have put the code here. I am using VS 2005, C#.Net. This is working fine when i am install the Win OS 2003 with ADS, but after few days it starts entering the...
0
by: johnathp | last post by:
hi there, I am trying to reset a password using this code snippet and it worked fine but only one concern I have is that, I need to let the user know if he has used a old password wrong. if the user...
0
by: Big Charles | last post by:
Hello, Programming in VS2003-ASP.NET 1.1, I have this problem: Using DirectoryEntry and without any admin user, how can I check if a domain account, that try to login, has expired? Scenario: User...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.