Loading cmdlets inside dll in powershell session

Recently I was exploring the way by which cmdlets inside a assembly should be loaded in powershell session.

Basically we need to use following powershell cmdlet to achieve this
Import-Module -Assembly <Assembly[]>

following powershell function can do it

function loadCmdletsInsideAssembly()
{
$assembly = [System.Reflection.Assembly]::LoadFile(–Enter location of assembly–);
$assemblyCollection = @($assembly);
Import-Module -Assembly $assemblyCollection
}
loadCmdletsInsideAssembly

Save the above function code inside ps1 file and invoke it from powershell command prompt.

Posted in Uncategorized | Tagged , , | Leave a comment

Using AD LDS with asp.net membership.

In order to consume AD LDS as data store for membership, We need to follow following steps [Environment – Windows server 2008]

  1. Install AD LDS [Control Panel – Administrative tools – Server manager – Roles – Add Roles – Check [Active directory  Lightweight directory services]
  2. Create AD LDS instance using  [Control Panel – Administrative tools – Active Directory Lightweight Directory Services Setup Wizard]
  3. Wizard : Setup options – Select  ‘A Unique instance’ Radio
  4. Wizard : Instance name – Enter the name as  ‘TestInstance’
  5. Wizard : Ports -Select the default ports.
  6. Wizard : Application directory partition – Create application partition Example [CN=testapp,DC=TestOrg,DC=Com]
  7. Wizard : File locations – keep default values
  8. Wizard : Service account selections – Select ‘This account’ option [Create a user under [Control panel – administrative tools – Computer management – local users and groups – New user] with name = ldapuser and password of your choice. Enter the username and password of new user in textboxes provided under ‘This account’ option.
  9. Wizard – AD LDS administrator – Select ‘This account’ option and select user created in previous step i.e. ldapuser [Step 8].
  10. Wizard – Importing LDIF Files – Check ‘MS-User.ldf’ and click next and wait till operation completes. You might be asked to enter username and password during the final step. Enter the credentials of ldapuser created in step 8.
  11. Now we have created LDAP instance.
  12. Click Start – Type [ADSI Edit] in Search programs and files textbox. Run ADSI Edit tool.
  13. Right click ADSI Edit node in left pane and choose ‘Connect’. Enter the details as (a). ConnectionPoint – CN=testapp,DC=TestOrg,DC=Com (b). Computer – localhost:389 [If you have selected a different port enter the same] (c). Click Advanced – Specify the credentials for ldapuser [step8]
  14. If everything goes well, you will be connected to the instance of LDAP you created just now.
  15. Right click node – CN=testapp,DC=TestOrg,DC=Com in left pane -> New-Object -> User -> ‘ldapadmin’ -> Finish [This will be the user we use in our asp.net application to connect with LDS.
  16. Click  CN=testapp,DC=TestOrg,DC=Com and you can see newly created ‘ldapadmin’ user in right pane.
  17. Right click the user and reset the password.
  18. Right click the user and select properties and make sure ‘msDS-UserAccountDisabled’ is set to FALSE. Double click the property name to change the value.
  19. You need to add this user to Admin Role. For that select  ‘CN=Roles’ from left pane. Select ‘CN=Administrator’ from right pane. Right click ‘CN=Administrator’ and select properties – members – Edit – click ‘Add DN..’ – Enter ‘CN=ldapadmin,CN=testapp,DC=TestOrg,DC=Com’. This will add ldapadmin user to administrator role.
  20. Make sure you follow step mentioned in blog –
    http://stackoverflow.com/questions/5616080/active-directory-lds-exception

Configuring the ASP.Net Application to use AD LDS

  1. Web.config – Add Connection string – <connectionStrings>
    <add name=”MyADProviderConnection” connectionString=”LDAP://localhost:389/CN=testapp,DC=TestOrg,DC=Com”/>
    </connectionStrings>
  2. Web.config – Configure membership provider –  <membership defaultProvider=”MyMembershipProvider”>
    <providers>
    <add name=”DefaultMembershipProvider”
    type=”System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”
    enableSearchMethods=”true”
    connectionStringName=”MyADProviderConnection”
    connectionUsername=”CN=ldapadmin,CN=testapp,DC=TestOrg,DC=Com”
    connectionPassword=”Specify ldapadmin password here set in step 17″
    connectionProtection=”None”
    />
    </providers>
    </membership>
  3. Application – Try Membership.CreateUser(txtUserName.Text, txtPassword.Text)
Posted in Active Directory | Tagged , , , , , , , , , , , , , , , | Leave a comment

Flex – Custom context menu item does not show up

I was implementing some functionality where in I wanted to add some custom items in the context menu of my flex application. But I found that when I contex menu item with ‘Settings’ word in it. I got no error but that particular item didnot appear in the context menu..Finally while trying to figure out a reason I stumbuled upon following url from adobe
http://livedocs.adobe.com/flex/3/langref/flash/ui/ContextMenuItem.html
This Url says that following words ‘Adobe
Macromedia
Flash Player
Settings’
cannot appear in a custom caption on their own or in conjunction with other words

Posted in Uncategorized | Tagged | Leave a comment

Flex – How to close popup anchor if mouse is clicked anywhere outside popup anchor

Recently I had an requirement where I was showing a calendar in popup anchor. Now if user clicks any where outside the popup anchor. The popup should be made invisible. Hence I used handled mouseDownOutside event of popup anchor and in the event handler I just set displayPopUp = false & it worked.

Posted in Uncategorized | Tagged | 3 Comments

Hello world!

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!

Posted in Uncategorized | 1 Comment