Subscribe RSS Join our Facebook Group Follow us on Twitter!
in Search

Microsoft and You

August 2011 - Posts

  • How to Split String User & Domain Active Directory

    Dalam Sharepoint, memungkinkan user login melalui AD User/Group, which is pada user AD mereka terdapat informasi Domain\User. Hal yang sama kita dapati ketika menggunakan SPUser LoginName yang tutorialnya anda dapat simak disini. Ok, pada tutorial berikut ini terdapat dua buah snippet code untuk men-split antara User dan Domain yang kita dapatkan dari AD User atau SPUser LoginName.

       1: using System.Security.Principal;
       2:  
       3: ....
       4:  
       5:         private string getDomain(IIdentity identity)
       6:         {
       7:             string s = identity.Name;
       8:             int stop = s.IndexOf("\\");
       9:             return (stop > -1) ? s.Substring(0, stop + 1) : string.Empty;
      10:         }
      11:  
      12:         private string getLogin(IIdentity identity)
      13:         {
      14:             string s = identity.Name;
      15:             int stop = s.IndexOf("\\");
      16:             return (stop > -1) ? identity.Substring(stop + 1, identity.Length - stop - 1) : string.Empty;
      17:         }
      18:  
      19:         .....
      20:         //Invoke Method
      21:         IIdentity id = System.Security.Principal.WindowsIdentity.GetCurrent();
      22:         string name = this.getLogin(id);
      23:         string domain = this.getDomain(id);

    Dari potongan kode diatas, kita menggunakan reference System.Security.Principal dan integrasi dengan IIdentity

       1: using Microsoft.SharePoint;
       2: .....
       3:  
       4:         private string getDomain(string spUser)
       5:         {
       6:             int stop = spUser.IndexOf("\\");
       7:             return (stop > -1) ? spUser.Substring(0, stop + 1) : string.Empty;
       8:         }
       9:  
      10:         private string getLogin(string spUser)
      11:         {
      12:             int stop = spUser.IndexOf("\\");
      13:             return (stop > -1) ? spUser.Substring(stop + 1, spUser.Length - stop - 1) : string.Empty;
      14:         }
      15:  
      16:         .....
      17:  
      18:         //Invoke method
      19:         SPUser sUser = SPContext.Current.Web.CurrentUser;
      20:         string user = this.getLogin(sUser.LoginName);
      21:         string domain = this.getDomain(sUser.LoginName);

    Hope this helps Smile

    306 Views, 0 Comment(s), Published on: 08-14-2011 11:32 by dani to Microsoft and You
    | More
    Filed under:
  • Adding module Session State in IIS Manager

    Mungkin anda pernah mengalami pesan warning seperti berikut pada web app Anda.

     image

    Penyebabnya tidak lain adalah web app yang anda menggunakan Session state , which is Session tersebut modulnya belum ditambahkan ke dalam konfigurasi IIS web app tersebut. So, berikut trik mengatasinya:

    1. Buka IIS 7 Manager, cari web app yang mengalami warning seperti diatas.

    2. Double klik Modules pada IIS section.

    3. Klik "Add Managed Module..." pada panel sebelah kanan.

    image

    4. Pada Add Managed Module dialog, enter "SessionState", dan pilih item pada dropdown:

    System.Web.SessionState.SessionStateModule, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

    image

    Hope this helps Smile

    222 Views, 0 Comment(s), Published on: 08-14-2011 10:31 by dani to Microsoft and You
    | More