Answer the question
In order to leave comments, you need to log in
How to login to Active Directory C# winforms?
Good afternoon!
There is a self-written EDMS (C# winforms) it is necessary to organize authorization through AD.
Question:
How to implement?
The following information needs to be retrieved from AD:
Answer the question
In order to leave comments, you need to log in
System.DirectoryServices.AccountManagement - you won't find a more suitable set of classes for your task. An article with auto-translation, so if nothing is clear at all, take this namespace and drive it into Google. I advise you to start correcting the need for Russian-language sources as soon as possible.
Here is my example of a similar one from one old project, it returns the full name, by login in AD:
private const string Domain = "<b>DOMAINNAME</b>";
static readonly DirectoryEntry Entry = new DirectoryEntry("LDAP://" + Domain);
static readonly DirectorySearcher Dsearch = new DirectorySearcher(Entry);
static SearchResultCollection _sResultSetCol;
public string GetAdFIOfromLogin(string fio)
{
try
{
fio = fio;
Dsearch.Filter = "(&(<b>samaccountname</b>=" + fio + "))";
_sResultSetCol = Dsearch.FindAll();
try
{
foreach (SearchResult sResultSet in _sResultSetCol)
{
if (GetProperty(sResultSet, "samaccountname") == fio)
{
return GetProperty(sResultSet, "<b>name</b>");
}
}
}
catch (Exception e)
{
return e.Message;
}
}
catch (Exception e)
{
return e.Message;
}
return "";
}
submissioncontlength
logoncount
cn
msexchuseraccountcontrol
msexchrbacpolicylink
streetaddress
msexchpoliciesincluded
info
company
postalcode
adspath
userprincipalname
instancetype
st
physicaldeliveryofficename
msexchtextmessagingstate
showinaddressbook
otherpager
samaccountname
manager
msexchrecipientdisplaytype
distinguishedname
memberof
msexchelcmailboxflags
objectcategory
mailnickname
legacyexclassaddresses
object
proxy
_
samaccounttype
homemdb
msexchhomeservername
telephonenumber
initials
countrycode
delivcontlength
co
publicdelegatesbl
givenname
name
msexchmailboxtemplatelink
l
badpwdcount
department
displayname
textencodedoraddress
useraccountcontrol
homemta
c
msexchuserculture
title
primarygroupid
codepage
sn
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question