public String getUser() { String user = User.Identity.Name.Split(new Char[] { '\\' })[1]; if (TextBox_Admin.Visible && TextBox_Admin.Text.Length > 0) { DirectorySearcher searcher = new DirectorySearcher("(&(name=" + TextBox_Admin.Text.ToString() + ")(objectClass=user))"); searcher.SearchRoot = entiry; searcher.PropertiesToLoad.Add("cn"); SearchResult res = searcher.FindOne(); if (res.Properties.Contains("cn") && res.Properties.Equals(TextBox_Admin.Text))//at this point the Exception is thrown user = TextBox_Admin.Text.ToString(); else { Label_Admin.Text = "Unknown User"; user = null; } } return user; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)