Monthly Archives: September 2008

LDAP query in PowerShell

I was looking for away of listing the account names of the active users in the AD, and Google suggested som more or less exotic ways of doing that. But this little PowerShell script is not too bad have in the toolbox: $Search = New-Object DirectoryServices.DirectorySearcher([ADSI]“LDAP://CN=Users,DC=domain,DC=local”) $Search.filter = “(&(objectCategory=person)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))” Foreach($result in $Search.Findall()){ $user = $result.GetDirectoryEntry() [...]

Are we alone?

Simple way to make sure there is only one instance of your application running in the window session. If you need there to be only one instance on the machine, change ‘Local’ to ‘Global’. static void Main() { using (Mutex m = new Mutex(true, @”Local\” + Application.ProductName)) { if (m.WaitOne(0, true)) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new [...]

Impersonation.RevertToSelf()

In a SharePoint web.config you will find the line <identity impersonate=”true”/> that causes all server code to be run in the context of the requesting client. So if you need your webpart to e.g. look up a user in the active directory (i.e. on the domain controller) you have a double hop issue. You can [...]

Follow

Get every new post delivered to your Inbox.