// Active Directory Access & Country Retrival
SearchResultCollection sResults = null;
string path = "LDAP://IPAddress"; .. (string path ="LDAP://10.0.2.15";)
DirectoryEntry dEntry = new DirectoryEntry(path, "Domain\\UserName", "Password");
DirectorySearcher dSearcher = new DirectorySearcher(dEntry);
dSearcher.Filter = "(&(objectClass=user)(SAMAccountName=" + myname + "))";
sResults = dSearcher.FindAll();
String DisplayNames = String.Empty;
foreach (SearchResult searchResult in sResults)
{
if (searchResult != null)
{
DisplayNames = searchResult.Properties["cn"][0].ToString();
if (DisplayNames.Contains("RKU.DK"))
{
String CountryName = searchResult.Properties["c"][0].ToString();
//("Country Name...:" + CountryName);
}
}
}
---------------------------------------------------------------------------------------------------
CODES in ACTIVE DIRECTORY Property:
OBJECTCLASS = "objectClass";
=>. CONTAINERNAME = "cn";
=>. LASTNAME = "sn";
=>. COUNTRYNOTATION = "c";
=>. CITY = "l";
=>. STATE = "st";
=>. TITLE = "title";
=>. POSTALCODE = "postalCode";
=>. PHYSICALDELIVERYOFFICENAME = "physicalDeliveryOfficeName";
=>. FIRSTNAME = "givenName";
=>. MIDDLENAME = "initials";
=>. DISTINGUISHEDNAME = "distinguishedName";
=>. INSTANCETYPE = "instanceType";
=>. WHENCREATED = "whenCreated";
=>. WHENCHANGED = "whenChanged";
=>. DISPLAYNAME = "displayName";
=>. USNCREATED = "uSNCreated";
=>. MEMBEROF = "memberOf";
=>. USNCHANGED = "uSNChanged";
=>. COUNTRY = "co";
=>. DEPARTMENT = "department";
=>. COMPANY = "company";
=>. PROXYADDRESSES = "proxyAddresses";
=>. STREETADDRESS = "streetAddress";
=>. DIRECTREPORTS = "directReports";
=>. NAME = "name";
=>. OBJECTGUID = "objectGUID";
=>. USERACCOUNTCONTROL = "userAccountControl";
=>. BADPWDCOUNT = "badPwdCount";
=>. CODEPAGE = "codePage";
=>. COUNTRYCODE = "countryCode";
=>. BADPASSWORDTIME = "badPasswordTime";
=>. LASTLOGOFF = "lastLogoff";
=>. LASTLOGON = "lastLogon";
=>. PWDLASTSET = "pwdLastSet";
=>. PRIMARYGROUPID = "primaryGroupID";
=>. OBJECTSID = "objectSid";
=>. ADMINCOUNT = "adminCount";
=>. ACCOUNTEXPIRES = "accountExpires";
=>. LOGONCOUNT = "logonCount";
=>. LOGINNAME = "sAMAccountName";
=>. SAMACCOUNTTYPE = "sAMAccountType";
=>. SHOWINADDRESSBOOK = "showInAddressBook";
=>. LEGACYEXCHANGEDN = "legacyExchangeDN";
=>. USERPRINCIPALNAME = "userPrincipalName";
=>. EXTENSION = "ipPhone";
=>. SERVICEPRINCIPALNAME = "servicePrincipalName";
=>. OBJECTCATEGORY = "objectCategory";
=>. DSCOREPROPAGATIONDATA = "dSCorePropagationData";
=>. LASTLOGONTIMESTAMP = "lastLogonTimestamp";
=>. EMAILADDRESS = "mail";
=>. MANAGER = "manager";
=>. MOBILE = "mobile";
=>. PAGER = "pager";
=>. FAX ="facsimileTelephoneNumber";
=>. HOMEPHONE = "homePhone";
No comments:
Post a Comment