Hello all,
I want to create a window application in which, during login user need not to pass username and password. it will come automatically from the active directory. i dont know how to that?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
kalyan BandarupalliPosted Jan 2, 2008, 7:27 AM
Hi the following code may help you.
ActiveDirectory objAD = new ActiveDirectory();
DirectoryEntry oDE = objAD.GetDirectoryEntry();
if(oDE.Properties.Contains("sAMAccountName"))
// it return the username
return Ode.Properties["sAMAccountName"][0].ToString();
the above code will return the current user who loggedin into the system.
you need to set the activedirectory path for the DirectoryEntry object
oDE.Path = "activedirectorypath";