I
I
Ivan Vyrov2015-07-19 15:25:27
Active Directory
Ivan Vyrov, 2015-07-19 15:25:27

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:

  • Login
  • Full Name
  • Password (if possible)
  • Groups in which he (user) is
Request:
Push to Russian-language sources on this topic

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stanislav Makarov, 2015-07-19
@Nipheris

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.

V
Vitaly Pukhov, 2015-07-20
@Neuroware

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 "";
        }

Here are the field names:
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
mail
title
primarygroupid
codepage
sn

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question