post Category: 荡寇志 post postDecember 18, 2009

            string ldapUrl = “LDAP://sz.szon.biz/DC=sz,DC=szon,DC=biz”;
            using (DirectoryEntry entry = new DirectoryEntry(ldapUrl, “sz\username”, “password”, AuthenticationTypes.Secure))
            {
                //search
                DirectorySearcher search = new DirectorySearcher(entry);
                search.Filter = “(SAMAccountName=” + userName + “)”;
                //load property,like displayName telephoneNumber otherTelephone
                search.PropertiesToLoad.Add(”mail”);
                SearchResult sr = search.FindOne();
                if (null != sr)
                {
                     //get property
                     sr.Properties[”mail”]
                }
            }

Sorry, no comments yet.

Write Your Comment

Comment Guidelines: Basic XHTML is allowed (a href, strong, em, code). All line breaks and paragraphs will be generated automatically.

You should have a name, right? 
Your email address, I promised I won't tell it to anyone. 
If you have a web site or blog, you can type the URL right here. 
This is where you type your comments. 
Remember my information for the next time I visit.