Özellikle kurum içi organizasyon ve personelin kayıtlarının tutulabileceği elverişli bir ortam sunar. Bir kurumda çalışan veya bir üniversitede okuyan öğrencilere çeşitli servisler sunmanız gerekir. Bunun için her servisin üzerinde çalıştığı makinada ayrı ayrı kullanıcı hesapları açmanız gerekebilir. Böyle olunca sistemin ve kullanıcıların yönetimi zorlaşır. LDAP kullanarak bu sorun çözülebilir.
Kısaca LDAP'da varolan tüm kullanıcıların listesine erişim için neler yapmanız gerekteğini anlatacağım.
DirectoryEntry ou = new DirectoryEntry("LDAP://ldapDomain (domain suffix)","ldapUserName","ldapUserPass"); DirectorySearcher src = new DirectorySearcher(ou); List<string> lstUserName = new List<string>(); src.Filter = ("(&(objectClass=user)(objectCategory=person))"); SearchResultCollection res = src.FindAll(); SearchResult result; if (res != null) { for (int i = 0; i < res.Count; i++) { result = res[i]; lstUserName.Add((string)result.Properties["samaccountname"][0]); } }
Kodu baştan aşağı olarak açıklayacak olursak ;
Burada öncelikli olarak arama yapacağımız dizini belirterek o dizine hangi kullanıcıyla giriş yapacağımızı belirtiyoruz.
Daha sonra
src.Filter = ("(&(objectClass=user)(objectCategory=person))");
kısmında ise arama yapacağımız filtreyi belirtmiş oluyoruz. Bu filtreyi isteklerinize göre düzenleyebilirsiniz.result.Properties["samaccountname"][0]
kısmında ise kullanıcıların Logon Name lerine ulaşmış oluyoruz.Burada kullanıcıların diğer özelliklerine ulaşmak istiyorsanız aşağıdaki attribute leri kullanabilirsiniz.
Name in AD | LDAP Name (header in CSV file) |
First Name | givenName |
Middle Name / Initials | initials |
Last Name | sn |
Logon Name | userPrincipalName |
Logon Name (Pre Windows 2000) | sAMAccountName |
Display Name | displayName |
Full Name | name/cn |
Description | description |
Office | physicalDeliveryOfficeName |
Telephone Number | telephoneNumber |
Web Page | wWWHomePage |
Password | password |
Street | streetAddress |
PO Box | postOfficeBox |
City | l |
State/Province | st |
Zip/Postal Code | postalCode |
Country | co |
Country 2 Digit Code - eg. US | c |
Country code -eg. for US country code is 840 | countryCode |
Group | memberOf |
Account Expires (use same date format as server) | accountExpires |
User Account Control | userAccountControl |
Profile Path | profilePath |
Login Script | scriptPath |
Home Folder | homeDirectory |
Home Drive | homeDrive |
Log on to | userWorkstations |
Home | homePhone |
Pager | pager |
Mobile | mobile |
Fax | facsimileTelephoneNumber |
IP Phone | ipPhone |
Notes | info |
Title | title |
Department | department |
Company | company |
Manager | manager |
Mail Alias | mailNickName |
Simple Display Name | displayNamePrintable |
Hide from Exchange address lists | msExchHideFromAddressLists |
Sending Message Size (KB) | submissionContLength |
Receiving Message Size (KB) | delivContLength |
Accept messages from Authenticated Users only | msExchRequireAuthToSendTo |
Reject Messages From | unauthOrig |
Accept Messages From | authOrig |
Send on Behalf | publicDelegates |
Forward To | altRecipient |
Deliver and Redirect | deliverAndRedirect |
Reciepient Limits | msExchRecipLimit |
Use mailbox store defaults | mDBuseDefaults |
Issue Warning at (KB) | mDBStorageQuota |
Prohibit Send at (KB) | mDBOverQuotaLimit |
Prohibit Send and receive at (KB) | mDBOverHardQuotaLimit |
Do not permanaently delete messages until the store has been backed up | deletedItemFlags |
keep deleted items for (days) | garbageCollPeriod |
Outlook Mobile Access | msExchOmaAdminWirelessEnable |
Outlook Web Access | protocolSettings |
Allow Terminal Server Logon | tsAllowLogon |
Terminal Services Profile Path | tsProfilePath |
Terminal Services Home Directory | tsHomeDir |
Terminal Services Home Drive | tsHomeDirDrive |
Start the following program at logon | tsInheritInitialProgram |
Starting Program file name | tsIntialProgram |
Start in | tsWorkingDir |
Connect client drive at logon | tsDeviceClientDrives |
Connect client printer at logon | tsDeviceClientPrinters |
Default to main client printer | tsDeviceClientDefaultPrinter |
End disconnected session | tsTimeOutSettingsDisConnections |
Active Session limit | tsTimeOutSettingsConnections |
Idle session limit | tsTimeOutSettingsIdle |
When session limit reached or connection broken | tsBrokenTimeOutSettings |
Allow reconnection | tsReConnectSettings |
Remote Control | tsShadowSettings |
Cok güzel bi paylasim...devamini bekliyoruz
YanıtlaSil