需要帮助来添加Active Directory [英] Need Help to add Active Directory

查看:58
本文介绍了需要帮助来添加Active Directory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好大师的

非常感谢您早日获得AD的帮助.
目前我的代码中难以包含AD功能.
希望有人能指导我正确的方向
要做的是从Web服务获取值并与AD进行检查并检索名称并更新数据库.

这是我的代码

Hello Guru''s

Thanks so much for earlier help to achieve AD .
At present am having trouble to include AD function in my code.
Hope some will guide me in the right direction
what am trying to do is get the value from webservice and check with AD and retrieve the name and update the database.

Here is my code

public ArrayList GetEmployeesFromService()
        {

       DirectoryEntry entry = new DirectoryEntry("GC://Test", "Test\\Test", "Ld@Test", AuthenticationTypes.Secure);

            System.DirectoryServices.DirectorySearcher search = new System.DirectoryServices.DirectorySearcher(entry);

            ArrayList resultList = new ArrayList(); 
          
            foreach (EmployeeExport  item in svcWrapper.GetEmployees)
            {
            
                resultList.Add(item.Department);
                
                System.Data.SqlClient.SqlConnection sqlConnection1 = new System.Data.SqlClient.SqlConnection(@"Data Source=SYDTESTSVR05;Initial Catalog=DLAPGateway_DEV;Integrated Security=SSPI");
                System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

            
                search.Filter = "(otherpager=" + item.EmployeeNumber + ")";
                

                
                 SearchResult result = search.FindOne();
                 ResultPropertyCollection fields = result.Properties;
                 foreach (String ldapField in fields.PropertyNames)
                {

                    if (ldapField == "name")
                        string name;
                        name =ldapField.ToString().Trim();
                }

            

                cmd.CommandText = "INSERT Person (EmployeeNo,NamePrefix,FirstName, MiddleName, LastName, NameSuffix,Contractor,HighestEducationalLevel, BirthDate, Gender ) VALUES("
                                                   + item.EmployeeNumber + ","
                                                   + "''" + item.Title + "''" + ","
                                                   + "''" + item.PreferredName + "''" + ","
                                                  //+ "''" + item.MiddleName + "''" + ","

                                                   + "''" + item.MiddleName.Replace("''", "''''") + "''" + ","
                                                    + "''" + item.Surname.Replace("''", "''''") + "''" + ","
                                                    + "''" + item.Suffix + "''" + ","
                                                    + "''" + item.PayPoint + "''" + ","
                                                    + "''" + item.HighestEducationLevel + "''" + ","
                                                    + "''" + item.BirthDate + "''" + ","
                                                    + "''" + item.Sex + "''" + ")";


                
                cmd.Connection = sqlConnection1;
                sqlConnection1.Open();
                cmd.ExecuteNonQuery();
                sqlConnection1.Close();

                
            }

            return resultList;  
        }

推荐答案

请参阅此链接,它可能对您有帮助
http://www.c-sharpcorner.com/articles/articlelisting.aspx? sectionid = 1& subsectionid = 1 [ ^ ]
Please see this link it may help to you
http://www.c-sharpcorner.com/articles/articlelisting.aspx?sectionid=1&subsectionid=1[^]


这篇关于需要帮助来添加Active Directory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆